Default should not be handled by database engine

This commit is contained in:
Anatoliy Chakkaev 2012-02-20 22:44:02 +04:00
parent 11b4436fd1
commit 35e872368a
2 changed files with 9 additions and 10 deletions

View File

@ -445,24 +445,23 @@ MySQL.prototype.propertySettingsSQL = function (model, prop) {
};
function datatype(p) {
var dt = '';
var dt = '';
switch (p.type.name) {
case 'String':
dt = 'VARCHAR(' + (p.limit || 255) + ')';
break;
break;
case 'Text':
dt = 'TEXT';
break;
break;
case 'Number':
dt = 'INT(' + (p.limit || 11) + ')';
break;
break;
case 'Date':
dt = 'DATETIME';
break;
break;
case 'Boolean':
dt = 'TINYINT(1)';
break;
}
dt += (typeof p.default !== 'undefined') ? ' DEFAULT ' + p.default.toString() : '';
return dt;
break;
}
return dt;
}

View File

@ -590,7 +590,7 @@ function testOrm(schema) {
test.ok(post.published === false);
post.updateAttributes({title: 'hey', published: true}, function () {
Post.find(id, function (err, post) {
test.ok(post.published === true);
test.ok(!!post.published, 'Update boolean field');
test.ok(post.id);
test.done();
});