meta data генератор: добавил при перепроливке ON CONFLICT (ID) DO UPDATE
This commit is contained in:
parent
9bebeda22c
commit
e80a94cd85
1 changed files with 19 additions and 2 deletions
|
|
@ -38,7 +38,9 @@ INSERT INTO <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="@
|
|||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>) values (<xsl:apply-templates select="@*" mode="values">
|
||||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>);
|
||||
</xsl:apply-templates>) ON CONFLICT (ID) DO UPDATE SET <xsl:apply-templates select="@*" mode="tablename-conflict-set">
|
||||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>;
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="*" mode="objects">
|
||||
|
|
@ -48,7 +50,9 @@ INSERT INTO <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="@
|
|||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>) values (<xsl:apply-templates select="@*" mode="values">
|
||||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>);
|
||||
</xsl:apply-templates>) ON CONFLICT (ID) DO UPDATE SET <xsl:apply-templates select="@*" mode="tablename-conflict-set">
|
||||
<xsl:with-param name="nodeName" select="$nodeName"/>
|
||||
</xsl:apply-templates>;
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*" mode="tablename">
|
||||
|
|
@ -78,6 +82,19 @@ INSERT INTO <xsl:value-of select="$dbTableName"/>(<xsl:apply-templates select="@
|
|||
<xsl:if test="position() != last()">, </xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*" mode="tablename-conflict-set">
|
||||
<xsl:param name="nodeName"/>
|
||||
<xsl:variable name="fieldName" select="name()"/>
|
||||
<xsl:variable name="dbFieldName"><xsl:call-template name='convertDbStyle'><xsl:with-param name='toconvert' select='name()'/></xsl:call-template></xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$dbFieldName='ID'">
|
||||
</xsl:when>
|
||||
<xsl:when test="xalan:nodeset($meta)/*/*[name()=$nodeName]/*[name()=$fieldName]">
|
||||
<xsl:value-of select="$dbFieldName"/> = EXCLUDED.<xsl:value-of select="$dbFieldName"/>
|
||||
<xsl:if test="position() != last()">, </xsl:if>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name='convertDbStyle'>
|
||||
<xsl:param name='toconvert' />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue