#90 multifield sqlite PKs; sqlite FKs; bugfix in css class 'key'

--HG--
extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%40101
This commit is contained in:
ondrej.zara
2010-04-09 06:46:01 +00:00
parent 3fcbbc9fd6
commit 968219a2e9
2 changed files with 28 additions and 13 deletions
+22 -8
View File
@@ -10,11 +10,12 @@
<xsl:text> (
</xsl:text>
<xsl:for-each select="row">
<xsl:variable name="name" select="@name" />
<xsl:value-of select="@name" />
<xsl:text> </xsl:text>
<xsl:value-of select="datatype" />
<xsl:text> </xsl:text>
<xsl:if test="@null = 0">
<xsl:text> NOT NULL </xsl:text>
@@ -24,12 +25,11 @@
<xsl:if test="default">
<xsl:text> DEFAULT </xsl:text>
<xsl:value-of select="default" />
<xsl:text> </xsl:text>
</xsl:if>
<xsl:variable name="name" select="@name" />
<!-- autoincrement/primary key after column - only when composed of 1 part -->
<xsl:for-each select="../key">
<xsl:if test="@type = 'PRIMARY'">
<xsl:if test="@type = 'PRIMARY' and count(child::part) = 1">
<xsl:for-each select="part">
<xsl:if test="$name = .">
<xsl:text> PRIMARY KEY</xsl:text>
@@ -42,18 +42,33 @@
<xsl:text> AUTOINCREMENT</xsl:text>
</xsl:if>
<!-- fk -->
<xsl:for-each select="relation">
<xsl:text> REFERENCES </xsl:text>
<xsl:value-of select="@table" />
<xsl:text> (</xsl:text>
<xsl:value-of select="@row" />
<xsl:text>)
</xsl:text>
</xsl:for-each>
<xsl:if test="not (position()=last())">
<xsl:text>,
</xsl:text>
</xsl:if>
</xsl:for-each>
<!-- keys -->
<!-- keys after table -->
<xsl:for-each select="key">
<xsl:if test="@type = 'UNIQUE'">
<xsl:if test="@type = 'UNIQUE' or (@type = 'PRIMARY' and count(child::part) > 1)">
<xsl:text>,
</xsl:text>
<xsl:text>UNIQUE (</xsl:text>
<xsl:choose>
<xsl:when test="@type = 'PRIMARY'">PRIMARY KEY</xsl:when>
<xsl:when test="@type = 'UNIQUE'">UNIQUE</xsl:when>
</xsl:choose>
<xsl:text> (</xsl:text>
<xsl:for-each select="part">
<xsl:value-of select="." />
@@ -73,7 +88,6 @@
</xsl:for-each>
<!-- fk -->
<xsl:for-each select="table">
<xsl:for-each select="key">
<xsl:if test="@type = 'INDEX'">
+1
View File
@@ -270,6 +270,7 @@ SQL.Row.prototype.redraw = function() {
var color = this.getColor();
this.dom.container.style.backgroundColor = color;
OZ.DOM.removeClass(this.dom.container,"primary");
OZ.DOM.removeClass(this.dom.container,"key");
if (this.isPrimary()) { OZ.DOM.addClass(this.dom.container,"primary"); }
if (this.isKey()) { OZ.DOM.addClass(this.dom.container,"key"); }
this.dom.selected.style.display = (this.selected ? "" : "none");