pgsql enhancements, thanks to Filip Rembialkowski

--HG--
extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%40116
This commit is contained in:
ondrej.zara
2011-01-12 07:42:56 +00:00
parent 1fdd1a3d3f
commit f819c4b3e9
2 changed files with 50 additions and 19 deletions
+2 -2
View File
@@ -23,10 +23,10 @@
<group label="Date &amp; Time" color="rgb(200,255,200)">
<type label="Date" length="0" sql="DATE" quote="'" />
<type label="Time" length="1" sql="TIME" quote="'" />
<type label="Time w/ TZ" length="0" sql="TIME WITH TIMEZONE" quote="'" />
<type label="Time w/ TZ" length="0" sql="TIME WITH TIME ZONE" quote="'" />
<type label="Interval" length="1" sql="INTERVAL" quote="'" />
<type label="Timestamp" length="1" sql="TIMESTAMP" quote="'" />
<type label="Timestamp w/ TZ" length="0" sql="TIMESTAMP WITH TIMEZONE" quote="'" />
<type label="Timestamp w/ TZ" length="0" sql="TIMESTAMP WITH TIME ZONE" quote="'" />
<type label="Timestamp wo/ TZ" length="0" sql="TIMESTAMP WITHOUT TIME ZONE" quote="'" />
</group>
+43 -12
View File
@@ -35,7 +35,20 @@
<xsl:value-of select="@name" />
<xsl:text>" </xsl:text>
<xsl:choose>
<xsl:when test="@autoincrement = 1">
<!-- use postgresql SERIAL shortcut for columns marked as
auto-increment. this creates integer column,
corresponding sequence, and default expression for the
column with nextval(). see:
http://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL
-->
<xsl:text> SERIAL</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="datatype" />
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:if test="@null = 0">
@@ -43,19 +56,17 @@
</xsl:if>
<xsl:if test="default">
<xsl:if test=" default != 'NULL' and default != NULL ">
<xsl:text>DEFAULT </xsl:text>
<xsl:value-of select="default" />
<xsl:text> </xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="comment">
<xsl:text>/* COMMENT '</xsl:text>
<xsl:call-template name="replace-substring">
<xsl:with-param name="value" select="comment" />
<xsl:with-param name="from" select='"&apos;"' />
<xsl:with-param name="to" select='"&apos;&apos;"' />
</xsl:call-template>
<xsl:text>' */</xsl:text>
<xsl:text>/* </xsl:text>
<xsl:value-of select="comment"/>
<xsl:text> */</xsl:text>
</xsl:if>
<xsl:if test="not (position()=last())">
@@ -85,22 +96,42 @@
</xsl:for-each>
<xsl:text>
)</xsl:text>
);
</xsl:text>
<xsl:if test="comment">
<xsl:text> /* </xsl:text>
<xsl:text>COMMENT ON TABLE "</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>" IS '</xsl:text>
<xsl:call-template name="replace-substring">
<xsl:with-param name="value" select="comment" />
<xsl:with-param name="from" select='"&apos;"' />
<xsl:with-param name="to" select='"&apos;&apos;"' />
</xsl:call-template>
<xsl:text>*/</xsl:text>
<xsl:text>';
</xsl:text>
</xsl:if>
<xsl:text>;
<!-- column comments -->
<xsl:for-each select="row">
<xsl:if test="comment">
<xsl:text>COMMENT ON COLUMN "</xsl:text>
<xsl:value-of select="../@name"/>
<xsl:text>"."</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>" IS '</xsl:text>
<xsl:call-template name="replace-substring">
<xsl:with-param name="value" select="comment" />
<xsl:with-param name="from" select='"&apos;"' />
<xsl:with-param name="to" select='"&apos;&apos;"' />
</xsl:call-template>
<xsl:text>';
</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
<!-- fk -->