better NULL handling
--HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4040
This commit is contained in:
+19
-8
@@ -65,9 +65,9 @@ SQL.Row.prototype.init = function(owner, title, data) {
|
|||||||
SQL.Visual.prototype.init.apply(this);
|
SQL.Visual.prototype.init.apply(this);
|
||||||
|
|
||||||
this.data.type = 0;
|
this.data.type = 0;
|
||||||
this.data.size = null;
|
this.data.size = "";
|
||||||
this.data.def = null;
|
this.data.def = null;
|
||||||
this.data.nll = false;
|
this.data.nll = true;
|
||||||
this.data.ai = false;
|
this.data.ai = false;
|
||||||
this.data.comment = "";
|
this.data.comment = "";
|
||||||
|
|
||||||
@@ -134,7 +134,11 @@ SQL.Row.prototype.mousedown = function(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SQL.Row.prototype.update = function(data) { /* update subset of row data */
|
SQL.Row.prototype.update = function(data) { /* update subset of row data */
|
||||||
|
if (data.nll && "def" in data && data.def.match(/^null$/i)) { data.def = null; }
|
||||||
|
|
||||||
for (var p in data) { this.data[p] = data[p]; }
|
for (var p in data) { this.data[p] = data[p]; }
|
||||||
|
if (!this.data.nll && this.data.def === null) { this.data.def = ""; }
|
||||||
|
|
||||||
var elm = this.getDataType();
|
var elm = this.getDataType();
|
||||||
for (var i=0;i<this.relations.length;i++) {
|
for (var i=0;i<this.relations.length;i++) {
|
||||||
var r = this.relations[i];
|
var r = this.relations[i];
|
||||||
@@ -252,8 +256,11 @@ SQL.Row.prototype.collapse = function() {
|
|||||||
|
|
||||||
SQL.Row.prototype.load = function() { /* put data to expanded form */
|
SQL.Row.prototype.load = function() { /* put data to expanded form */
|
||||||
this.dom.name.value = this.getTitle();
|
this.dom.name.value = this.getTitle();
|
||||||
this.dom.def.value = this.data.def;
|
var def = this.data.def;
|
||||||
this.dom.size.value = this.data.size || null;
|
if (def === null) { def = "NULL"; }
|
||||||
|
|
||||||
|
this.dom.def.value = def;
|
||||||
|
this.dom.size.value = this.data.size;
|
||||||
this.dom.nll.checked = !this.data.nll;
|
this.dom.nll.checked = !this.data.nll;
|
||||||
this.dom.ai.checked = this.data.ai;
|
this.dom.ai.checked = this.data.ai;
|
||||||
}
|
}
|
||||||
@@ -348,10 +355,14 @@ SQL.Row.prototype.toXML = function() {
|
|||||||
if (elm.getAttribute("length") == "1" && this.data.size) { t += "("+this.data.size+")"; }
|
if (elm.getAttribute("length") == "1" && this.data.size) { t += "("+this.data.size+")"; }
|
||||||
xml += "<datatype>"+t+"</datatype>";
|
xml += "<datatype>"+t+"</datatype>";
|
||||||
|
|
||||||
if (this.data.def) {
|
if (this.data.def || this.data.def === null) {
|
||||||
var q = elm.getAttribute("quote");
|
var q = elm.getAttribute("quote");
|
||||||
var d = this.data.def || "";
|
var d = this.data.def;
|
||||||
if (d != "NULL" && d != "null" && d != "CURRENT_TIMESTAMP") { d = q+d+q; }
|
if (d === null) {
|
||||||
|
d = "NULL";
|
||||||
|
} else if (d != "CURRENT_TIMESTAMP") {
|
||||||
|
d = q+d+q;
|
||||||
|
}
|
||||||
xml += "<default>"+d+"</default>";
|
xml += "<default>"+d+"</default>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +385,7 @@ SQL.Row.prototype.fromXML = function(node) {
|
|||||||
var name = node.getAttribute("name");
|
var name = node.getAttribute("name");
|
||||||
this.setTitle(name);
|
this.setTitle(name);
|
||||||
|
|
||||||
var obj = { type:0, size:null };
|
var obj = { type:0, size:"" };
|
||||||
obj.nll = (node.getAttribute("null") == "1");
|
obj.nll = (node.getAttribute("null") == "1");
|
||||||
obj.ai = (node.getAttribute("autoincrement") == "1");
|
obj.ai = (node.getAttribute("autoincrement") == "1");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user