Skip to content
Browse files

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

  • Loading branch information...
2 parents 797ae84 + ab4844b commit d8981056f58c64a9eef5913413aff9ac7082c7c7 @1602 committed Sep 26, 2012
Showing with 19 additions and 4 deletions.
  1. +1 −1 lib/abstract-class.js
  2. +6 −2 lib/adapters/mongoose.js
  3. +12 −1 lib/adapters/postgres.js
View
2 lib/abstract-class.js
@@ -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
8 lib/adapters/mongoose.js
@@ -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
13 lib/adapters/postgres.js
@@ -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 ) {

0 comments on commit d898105

Please sign in to comment.
Something went wrong with that request. Please try again.