不要怂,就是干,撸起袖子干!

Commit a08d1ca4 by Daniel Durante

Fixed several issues and added in a spec for saving records with no primary keys.

1 parent 7287f332
Showing with 26 additions and 9 deletions
......@@ -151,11 +151,11 @@ module.exports = (function() {
if (!options.include[daoName]) {
options.include[daoName] = this.getAssociationByAlias(daoName).target
}
}.bind(this))
}
}.bind(this));
// whereCollection is used for non-primary key updates
this.options.whereCollection = optcpy.where || undefined;
// whereCollection is used for non-primary key updates
this.options.whereCollection = options.where || undefined;
}
return this.QueryInterface.select(this, this.tableName, options, { type: 'SELECT', hasJoin: hasJoin })
}
......@@ -217,14 +217,14 @@ module.exports = (function() {
if (!options.include[daoName]) {
options.include[daoName] = this.getAssociationByAlias(daoName).target
}
}.bind(this))
}.bind(this));
// whereCollection is used for non-primary key updates
this.options.whereCollection = options.where || undefined;
}
options.limit = 1
// whereCollection is used for non-primary key updates
this.options.whereCollection = optcpy.where || undefined;
return this.QueryInterface.select(this, this.tableName, options, { plain: true, type: 'SELECT', hasJoin: hasJoin })
}
......
......@@ -19,9 +19,17 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
touchedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
aNumber: { type: DataTypes.INTEGER }
})
self.HistoryLog = sequelize.define('HistoryLog', {
someText: { type: DataTypes.STRING },
aNumber: { type: DataTypes.INTEGER },
aRandomId: { type: DataTypes.INTEGER }
})
},
onComplete: function() {
self.User.sync({ force: true }).success(done)
self.User.sync({ force: true }).success(function(){
self.HistoryLog.sync({ force: true }).success(done)
})
}
})
})
......@@ -67,6 +75,15 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
done()
})
})
it('saves a record with no primary key', function(done){
this.HistoryLog.create({ someText: 'Some random text', aNumber: 3, aRandomId: 5 }).success(function(log) {
log.updateAttributes({ aNumber: 5 }).success(function(newLog){
expect(newLog.aNumber).toEqual(5)
done()
})
})
})
})
describe('toJSON', function toJSON() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!