Fixing some bugs, which fix default values and length of fields in mysql adapter
This commit is contained in:
parent
04cbad35fd
commit
7569a923c8
|
@ -105,7 +105,7 @@ MySQL.prototype.toDatabase = function (prop, val) {
|
|||
' AND ' +
|
||||
this.toDatabase(prop, val[1]);
|
||||
} else if (operator == 'inq' || operator == 'nin') {
|
||||
if (!(val.propertyIsEnumerable('length')) && typeof val === 'object' && typeof val.length === 'number') { //if value is array
|
||||
if (!(val.propertyIsEnumerable('length')) && typeof val === 'object' && typeof val.length === 'number') { //if value is array
|
||||
return val.join(',');
|
||||
} else {
|
||||
return val;
|
||||
|
@ -413,17 +413,24 @@ MySQL.prototype.propertySettingsSQL = function (model, prop) {
|
|||
};
|
||||
|
||||
function datatype(p) {
|
||||
var dt = '';
|
||||
switch (p.type.name) {
|
||||
case 'String':
|
||||
return 'VARCHAR(' + (p.limit || 255) + ')';
|
||||
dt = 'VARCHAR(' + (p.limit || 255) + ')';
|
||||
break;
|
||||
case 'Text':
|
||||
return 'TEXT';
|
||||
dt = 'TEXT';
|
||||
break;
|
||||
case 'Number':
|
||||
return 'INT(11)';
|
||||
dt = 'INT(' + (p.limit || 11) + ')';
|
||||
break;
|
||||
case 'Date':
|
||||
return 'DATETIME';
|
||||
dt = 'DATETIME';
|
||||
break;
|
||||
case 'Boolean':
|
||||
return 'TINYINT(1)';
|
||||
}
|
||||
}
|
||||
|
||||
dt = 'TINYINT(1)';
|
||||
break;
|
||||
}
|
||||
dt += (typeof p.default !== 'undefined') ? ' DEFAULT ' + p.default.toString() : '';
|
||||
return dt;
|
||||
}
|
Loading…
Reference in New Issue