Changeset 3343


Ignore:
Timestamp:
08/09/13 12:00:37 (11 years ago)
Author:
mwindhouwer
Message:

M dc_sql.xsl

  • handle deletes of fields in a row by turning them into inserts of/updates to NULL
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cats/ISOcat/trunk/mod-ISOcat-access-data/access/dc_sql.xsl

    r2710 r3343  
    66        <xsl:param name="pid" select="'http://www.isocat.org/datcat/'"/>
    77       
    8         <xsl:variable name="debug-flag" select="$debug='t'"/>
     8        <xsl:variable name="debug-flag" select="starts-with($debug,'t')"/>
    99
    1010        <xsl:param name="user" select="0"/>
     
    876876                                                </xsl:for-each>
    877877                                        </xsl:when>
     878                                        <xsl:when test="(count($deletes)=1) and exists($deletes[@sql:type='field']) and exists(index-of(tokenize($table/@diff:action,'\s+'),'update'))">
     879                                                <xsl:if test="$debug-flag">
     880                                                        <xsl:message>DBG: turn delete for field[<xsl:value-of select="current-grouping-key()"/>] into an update to NULL</xsl:message>
     881                                                </xsl:if>
     882                                                <xsl:for-each select="$deletes">
     883                                                        <xsl:copy>
     884                                                                <xsl:attribute name="diff:action" select="'update'"/>
     885                                                                <xsl:attribute name="sql:type" select="'NULL'"/>
     886                                                                <xsl:apply-templates select="@* except @diff:action except @sql:type" mode="simplify"/>
     887                                                        </xsl:copy>
     888                                                </xsl:for-each>
     889                                        </xsl:when>
     890                                        <xsl:when test="(count($deletes)=1) and exists($deletes[@sql:type='field']) and $table/@diff:action='insert'">
     891                                                <xsl:if test="$debug-flag">
     892                                                        <xsl:message>DBG: turn delete for field[<xsl:value-of select="current-grouping-key()"/>] into an insert of NULL</xsl:message>
     893                                                </xsl:if>
     894                                                <xsl:for-each select="$deletes">
     895                                                        <xsl:copy>
     896                                                                <xsl:attribute name="diff:action" select="'insert'"/>
     897                                                                <xsl:attribute name="sql:type" select="'NULL'"/>
     898                                                                <xsl:apply-templates select="@* except @diff:action except @sql:type" mode="simplify"/>
     899                                                        </xsl:copy>
     900                                                </xsl:for-each>
     901                                        </xsl:when>
    878902                                        <xsl:otherwise>
    879903                                                <xsl:copy-of select="current-group()"/>
     
    896920                <xsl:param name="table" select="parent::*"/>
    897921                <xsl:if test="$debug-flag">
    898                         <xsl:message terminate="no">table[<xsl:value-of select="name($table)"/>] field[<xsl:value-of select="name()"/>] [<xsl:value-of select="exists(..)"/>]</xsl:message>
     922                        <xsl:message terminate="no">DBG: table[<xsl:value-of select="name($table)"/>] field[<xsl:value-of select="name()"/>] [<xsl:value-of select="exists(..)"/>]</xsl:message>
    899923                </xsl:if>
    900924                <xsl:choose>
     
    967991                        <xsl:when test="@sql:type='foreign key'">
    968992                                <xsl:value-of select="."/>
     993                        </xsl:when>
     994                        <xsl:when test="@sql:type='NULL'">
     995                                <xsl:text>NULL</xsl:text>
    969996                        </xsl:when>
    970997                        <xsl:otherwise>
Note: See TracChangeset for help on using the changeset viewer.