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

Commit a5b4c60a by Mick Hansen

[fix/bulkCreate] allow values to be passed for auto incremented columns, fixes #1186

1 parent cd1b89a1
...@@ -311,7 +311,7 @@ module.exports = (function() { ...@@ -311,7 +311,7 @@ module.exports = (function() {
tuples.push("(" + tuples.push("(" +
Utils._.map(attrValueHash, function(value, key){ Utils._.map(attrValueHash, function(value, key){
if (serials.indexOf(key) !== -1) { if (serials.indexOf(key) !== -1) {
return 'DEFAULT'; return value || 'DEFAULT';
} }
return this.escape(value) return this.escape(value)
}.bind(this)).join(",") + }.bind(this)).join(",") +
......
...@@ -906,6 +906,23 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -906,6 +906,23 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('should allow autoincremented attributes to be set', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.bulkCreate([
{id: 5},
{id: 10}
]).done(function (err) {
expect(err).not.to.be.ok
Worker.findAll({order: 'id ASC'}).done(function (err, workers) {
expect(workers[0].id).to.equal(5)
expect(workers[1].id).to.equal(10)
done()
})
})
})
})
describe('enums', function() { describe('enums', function() {
it('correctly restores enum values', function(done) { it('correctly restores enum values', function(done) {
var self = this var self = this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!