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

Commit 0c591847 by durango

Merge pull request #689 from janmeier/pgID

Fixes #644
2 parents 7db160ca 872a0bea
......@@ -292,7 +292,18 @@ module.exports = (function() {
attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, this.options.omitNull)
var query = "INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>) RETURNING *;"
, returning = removeSerialsFromHash(tableName, attrValueHash)
// Remove serials that are null or undefined, which causes an error in PG
Utils._.forEach(attrValueHash, function(value, key, hash) {
if (tables[tableName]) {
switch (tables[tableName][key]) {
case 'bigserial':
case 'serial':
if ([null, undefined].indexOf(hash[key]) !== -1) delete hash[key]
break
}
}
});
var replacements = {
table: this.quoteIdentifiers(tableName)
......
......@@ -518,6 +518,17 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
})
})
it('allows setting custom IDs', function (done) {
this.User.create({ id: 42 }).success(function (user) {
expect(user.id).toEqual(42)
this.User.find(42).success(function (user) {
expect(user).toBeDefined()
done()
})
}.bind(this))
})
describe('enums', function() {
before(function(done) {
this.Item = this.sequelize.define('Item', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!