Commits

Yury Shulaev committed fb0ccbe

add UNSIGNED support

  • Participants
  • Parent commits 1a214db

Comments (0)

Files changed (5)

backend/php-mysql+file/mysql_import.php

 				$null = ($row["IS_NULLABLE"] == "YES" ? "0" : "1");
 				$def = $row["COLUMN_DEFAULT"];
 				$ai = (preg_match("/auto_increment/i",$row["EXTRA"]) ? "1" : "0");
+				$unsigned = (preg_match("/unsigned/i",$row["COLUMN_TYPE"]) ? "1" : "0");
 				if ($def == "NULL") { $def = ""; }
-				$xml .= '<row name="'.$name.'" null="'.$null.'" autoincrement="'.$ai.'">';
+				$xml .= '<row name="'.$name.'" null="'.$null.'" autoincrement="'.$ai.'" unsigned="'.$unsigned.'">';
 				$xml .= '<datatype>'.preg_replace_callback('/^(\w+)/', function ($matches) { return strtoupper($matches[0]); }, $type).'</datatype>';
 				$xml .= '<default>'.$def.'</default>';
 				if ($comment) { $xml .= '<comment>'.$comment.'</comment>'; }

db/mysql/output.xsl

 			<xsl:value-of select="datatype" />
 			<xsl:text></xsl:text>
 
+			<xsl:if test="@unsigned = 1">
+				<xsl:text> UNSIGNED</xsl:text>
+			</xsl:if>
+
 			<xsl:choose>
 				<xsl:when test="@null = 0"> NOT NULL</xsl:when>
 				<xsl:otherwise> NULL</xsl:otherwise>
 		<xsl:for-each select="row">
 			<xsl:for-each select="relation">
 				<xsl:choose>
-					<xsl:when test="@type='dummy'"></xsl:when>
-					<xsl:when test="@type='cascade'">
+					<xsl:when test="@type = 'dummy'"></xsl:when>
+					<xsl:when test="@type = 'cascade'">
 						<xsl:text>ALTER TABLE `</xsl:text>
 						<xsl:value-of select="../../@name" />
 						<xsl:text>` ADD FOREIGN KEY (</xsl:text>

js/wwwsqldesigner.js

 	this.data.def = null;
 	this.data.nll = false;
 	this.data.ai = false;
+	this.data.unsigned = false;
 	this.data.comment = "";
 
 	if (data) { this.update(data); }
 	this.dom.ai.type = "checkbox";
 	elms.push(["ai",this.dom.ai]);
 
+	this.dom.unsigned = OZ.DOM.elm("input");
+	this.dom.unsigned.type = "checkbox";
+	elms.push(["unsigned",this.dom.unsigned]);
+
 	this.dom.nll = OZ.DOM.elm("input");
 	this.dom.nll.type = "checkbox";
 	elms.push(["null",this.dom.nll]);
 		def: this.dom.def.value,
 		size: this.dom.size.value,
 		nll: this.dom.nll.checked,
-		ai: this.dom.ai.checked
+		ai: this.dom.ai.checked,
+		unsigned: this.dom.unsigned.checked
 	}
 
 	OZ.DOM.clear(this.dom.container);
 	this.dom.size.value = this.data.size;
 	this.dom.nll.checked = this.data.nll;
 	this.dom.ai.checked = this.data.ai;
+	this.dom.unsigned.checked = this.data.unsigned;
 }
 
 SQL.Row.prototype.redraw = function() {
 	var t = this.getTitle().replace(/"/g,"&quot;");
 	var nn = (this.data.nll ? "1" : "0");
 	var ai = (this.data.ai ? "1" : "0");
-	xml += '<row name="'+t+'" null="'+nn+'" autoincrement="'+ai+'">\n';
+	var unsigned = (this.data.unsigned ? "1" : "0");
+	xml += '<row name="'+t+'" null="'+nn+'" autoincrement="'+ai+'" unsigned="'+unsigned+'">\n';
 
 	var elm = this.getDataType();
 	var t = elm.getAttribute("sql");
 	var obj = { type:0, size:"" };
 	obj.nll = (node.getAttribute("null") == "1");
 	obj.ai = (node.getAttribute("autoincrement") == "1");
+	obj.unsigned = (node.getAttribute("unsigned") == "1");
 
 	var cs = node.getElementsByTagName("comment");
 	if (cs.length && cs[0].firstChild) { obj.comment = cs[0].firstChild.nodeValue; }
 	<string name="def">Default</string>
 	<string name="notnull">NOT NULL</string>
 	<string name="null">NULL</string>
-	<string name="ai">Autoincrement</string>
+	<string name="ai">AUTO_INCREMENT</string>
+	<string name="unsigned">UNSIGNED</string>
 	<string name="comment">Edit comment</string>
 	<string name="commenttext">Enter comment for this field</string>
 
 	<string name="def">По умолчанию</string>
 	<string name="notnull">NOT NULL</string>
 	<string name="null">NULL</string>
-	<string name="ai">Autoincrement</string>
+	<string name="ai">AUTO_INCREMENT</string>
+	<string name="unsigned">UNSIGNED</string>
 	<string name="comment">Изменить коментарий</string>
 	<string name="commenttext">Введите коментарий для этого поля</string>