From b93b2c36e913f26aa9466cc9bca7027225794ec3 Mon Sep 17 00:00:00 2001 From: "ondrej.zara" Date: Mon, 4 May 2009 06:54:32 +0000 Subject: [PATCH] better NULL handling --HG-- extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4040 --- js/wwwsqldesigner.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/js/wwwsqldesigner.js b/js/wwwsqldesigner.js index e31167d..638364e 100644 --- a/js/wwwsqldesigner.js +++ b/js/wwwsqldesigner.js @@ -65,9 +65,9 @@ SQL.Row.prototype.init = function(owner, title, data) { SQL.Visual.prototype.init.apply(this); this.data.type = 0; - this.data.size = null; + this.data.size = ""; this.data.def = null; - this.data.nll = false; + this.data.nll = true; this.data.ai = false; this.data.comment = ""; @@ -134,7 +134,11 @@ SQL.Row.prototype.mousedown = function(e) { } 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]; } + if (!this.data.nll && this.data.def === null) { this.data.def = ""; } + var elm = this.getDataType(); for (var i=0;i"; - if (this.data.def) { + if (this.data.def || this.data.def === null) { var q = elm.getAttribute("quote"); - var d = this.data.def || ""; - if (d != "NULL" && d != "null" && d != "CURRENT_TIMESTAMP") { d = q+d+q; } + var d = this.data.def; + if (d === null) { + d = "NULL"; + } else if (d != "CURRENT_TIMESTAMP") { + d = q+d+q; + } xml += ""+d+""; } @@ -374,7 +385,7 @@ SQL.Row.prototype.fromXML = function(node) { var name = node.getAttribute("name"); this.setTitle(name); - var obj = { type:0, size:null }; + var obj = { type:0, size:"" }; obj.nll = (node.getAttribute("null") == "1"); obj.ai = (node.getAttribute("autoincrement") == "1");