#16 different datatype and pk datatype

--HG--
extra : convert_revision : svn%3Ab267cdba-c1da-11dd-874b-8bacd04a0a74/trunk%4060
This commit is contained in:
ondrej.zara
2009-11-10 13:31:40 +00:00
parent 0ede2caa6c
commit 09da598d90
2 changed files with 33 additions and 3 deletions
+2 -2
View File
@@ -5,8 +5,8 @@
<type label="Small Integer" length="0" sql="SMALLINT" quote="" />
<type label="Big Integer" length="0" sql="BIGINT" quote="" />
<type label="Decimal" length="1" sql="DECIMAL" re="numeric" quote="" />
<type label="Serial" length="0" sql="SERIAL" re="SERIAL4" quote="" />
<type label="Big Serial" length="0" sql="BIGSERIAL" re="SERIAL8" quote="" />
<type label="Serial" length="0" sql="SERIAL" re="SERIAL4" fk="Integer" quote="" />
<type label="Big Serial" length="0" sql="BIGSERIAL" re="SERIAL8" fk="Big Integer" quote="" />
<type label="Real" length="0" sql="BIGINT" quote="" />
<type label="Single precision" length="0" sql="FLOAT" quote="" />
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote="" />
+31 -1
View File
@@ -134,6 +134,7 @@ SQL.Row.prototype.mousedown = function(e) {
}
SQL.Row.prototype.update = function(data) { /* update subset of row data */
var des = SQL.Designer;
if (data.nll && data.def && data.def.match(/^null$/i)) { data.def = null; }
for (var p in data) { this.data[p] = data[p]; }
@@ -142,7 +143,7 @@ SQL.Row.prototype.update = function(data) { /* update subset of row data */
var elm = this.getDataType();
for (var i=0;i<this.relations.length;i++) {
var r = this.relations[i];
if (r.row1 == this) { r.row2.update({type:this.data.type,size:this.data.size}); }
if (r.row1 == this) { r.row2.update({type:des.getFKTypeFor(this.data.type),size:this.data.size}); }
}
this.redraw();
}
@@ -1522,6 +1523,7 @@ SQL.RowManager.prototype.tableClick = function(e) { /* create relation after cli
p = p.replace(/%R/g,r1.getTitle());
var r2 = t2.addRow(p, r1.data);
r2.update({"type":SQL.Designer.getFKTypeFor(r1.data.type)});
r2.update({"ai":false});
this.owner.addRelation(r1, r2);
}
@@ -2044,6 +2046,9 @@ SQL.Designer.prototype.init = function() {
this.flag = 2;
this.typeIndex = false;
this.fkTypeFor = false;
this.requestLanguage();
this.requestDB();
@@ -2314,3 +2319,28 @@ SQL.Designer.prototype.removeSelection = function() {
if (sel.empty) { sel.empty(); }
if (sel.removeAllRanges) { sel.removeAllRanges(); }
}
SQL.Designer.prototype.getTypeIndex = function(label) {
if (!this.typeIndex) {
this.typeIndex = {};
var types = window.DATATYPES.getElementsByTagName("type");
for (var i=0;i<types.length;i++) {
var l = types[i].getAttribute("label");
if (l) this.typeIndex[l] = i;
}
}
return this.typeIndex[label];
}
SQL.Designer.prototype.getFKTypeFor = function(typeIndex) {
if (!this.fkTypeFor) {
var types = window.DATATYPES.getElementsByTagName("type");
this.fkTypeFor = {};
for (var i=0;i<types.length;i++) {
this.fkTypeFor[i] = i;
var fk = types[i].getAttribute("fk");
if (fk) { this.fkTypeFor[i] = this.getTypeIndex(fk); }
}
}
return this.fkTypeFor[typeIndex];
}