Merge branch 'master' of github.com:1602/jugglingdb

This commit is contained in:
Anatoliy Chakkaev 2012-09-26 08:23:26 +04:00
commit d8981056f5
3 changed files with 19 additions and 4 deletions

View File

@ -606,7 +606,7 @@ AbstractClass.prototype.updateAttributes = function updateAttributes(data, cb) {
inst.isValid(function (valid) {
if (!valid) {
if (cb) {
cb(new Error('Validation error'));
cb(new Error('Validation error'), inst);
}
} else {
update();

View File

@ -48,8 +48,12 @@ function MongooseAdapter(client) {
MongooseAdapter.prototype.define = function (descr) {
var props = {};
Object.keys(descr.properties).forEach(function (key) {
props[key] = descr.properties[key].type;
if (props[key].name === 'Text' || props[key].name === 'JSON') props[key] = String;
props[key] = {};
props[key].type = descr.properties[key].type;
if (props[key].type.name === 'Text' || props[key].type.name === 'JSON') props[key].type = String;
if (descr.properties[key].index) {
props[key].index = descr.properties[key].index;
}
});
var schema = new mongoose.Schema(props);
this._models[descr.model.modelName] = mongoose.model(descr.model.modelName, schema);

View File

@ -164,7 +164,18 @@ PG.prototype.toDatabase = function (prop, val) {
return this.toDatabase(prop, val[0]) + ' AND ' + this.toDatabase(prop, val[1]);
}
}
if (prop.type.name === 'Number') return val;
if (prop.type.name === 'Number') {
if (!val && val!=0) {
if( prop.autoIncrement ) {
return 'DEFAULT';
}
else {
return 'NULL';
}
}
return val
};
if (prop.type.name === 'Date') {
if (!val) {
if( prop.autoIncrement ) {