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

Commit e573e740 by Jan Aagaard Meier

Stuff

1 parent 3601fa16
...@@ -93,17 +93,18 @@ module.exports = (function() { ...@@ -93,17 +93,18 @@ module.exports = (function() {
modifierLastIndex = -1 modifierLastIndex = -1
} }
var dataTypeString = dataType
if (Utils._.includes(dataType, 'PRIMARY KEY')) { if (Utils._.includes(dataType, 'PRIMARY KEY')) {
if (Utils._.includes(dataType, 'INTEGER')) { if (Utils._.includes(dataType, 'INTEGER')) {
dataType = 'INTEGER PRIMARY KEY' // Only INTEGER is allowed for primary key, see https://github.com/sequelize/sequelize/issues/969 (no lenght, unsigned etc) dataTypeString = 'INTEGER PRIMARY KEY' // Only INTEGER is allowed for primary key, see https://github.com/sequelize/sequelize/issues/969 (no lenght, unsigned etc)
} }
if (needsMultiplePrimaryKeys) { if (needsMultiplePrimaryKeys) {
primaryKeys.push(attr) primaryKeys.push(attr)
dataType = dataType.replace(/PRIMARY KEY/, 'NOT NULL') dataTypeString = dataType.replace(/PRIMARY KEY/, 'NOT NULL')
} }
} }
attrStr.push(this.quoteIdentifier(attr) + " " + dataType) attrStr.push(this.quoteIdentifier(attr) + " " + dataTypeString)
} }
} }
......
...@@ -532,26 +532,7 @@ module.exports = (function() { ...@@ -532,26 +532,7 @@ module.exports = (function() {
} }
} }
return new Utils.CustomEventEmitter(function(emitter) { return this.queryAndEmit([sql, dao, options], 'update')
var chainer = new Utils.QueryChainer()
chainer.add(self, 'queryAndEmit', [[sql, dao, options], 'delete'])
chainer.runSerially()
.success(function(results){
emitter.query = { sql: sql }
emitter.emit('success', results[0])
emitter.emit('sql', sql)
})
.error(function(err) {
emitter.query = { sql: sql }
emitter.emit('error', err)
emitter.emit('sql', sql)
})
.on('sql', function(sql) {
emitter.emit('sql', sql)
})
}).run()
} }
QueryInterface.prototype.bulkUpdate = function(tableName, values, identifier, options) { QueryInterface.prototype.bulkUpdate = function(tableName, values, identifier, options) {
......
...@@ -85,7 +85,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() { ...@@ -85,7 +85,7 @@ describe(Support.getTestDialectTeaser("BelongsTo"), function() {
self.sequelize.dropAllSchemas().done(function() { self.sequelize.dropAllSchemas().done(function() {
self.sequelize.createSchema('archive').done(function () { self.sequelize.createSchema('archive').done(function () {
self.sequelize.sync({force: true}).done(function () { self.sequelize.sync({force: true }).done(function () {
User.create({ username: 'foo', gender: 'male' }).success(function(user) { User.create({ username: 'foo', gender: 'male' }).success(function(user) {
Task.create({ title: 'task', status: 'inactive' }).success(function(task) { Task.create({ title: 'task', status: 'inactive' }).success(function(task) {
task.setUserXYZ(user).success(function() { task.setUserXYZ(user).success(function() {
......
...@@ -279,11 +279,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -279,11 +279,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
bCol: { type: Sequelize.STRING, unique: 'a_and_b' } bCol: { type: Sequelize.STRING, unique: 'a_and_b' }
}) })
User.sync({ force: true }).on('sql', function(sql) { User.sync({ force: true }).on('sql', _.after(2, function(sql) {
expect(sql).to.match(/UNIQUE\s*(uniq_UserWithUniqueUsernames_username_email)?\s*\([`"]?username[`"]?, [`"]?email[`"]?\)/) expect(sql).to.match(/UNIQUE\s*(uniq_UserWithUniqueUsernames_username_email)?\s*\([`"]?username[`"]?, [`"]?email[`"]?\)/)
expect(sql).to.match(/UNIQUE\s*(uniq_UserWithUniqueUsernames_aCol_bCol)?\s*\([`"]?aCol[`"]?, [`"]?bCol[`"]?\)/) expect(sql).to.match(/UNIQUE\s*(uniq_UserWithUniqueUsernames_aCol_bCol)?\s*\([`"]?aCol[`"]?, [`"]?bCol[`"]?\)/)
done() done()
}) }))
}) })
it('allows us to customize the error message for unique constraint', function(done) { it('allows us to customize the error message for unique constraint', function(done) {
...@@ -1447,7 +1447,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1447,7 +1447,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should be able to reference a table with a schema set', function(done) { it('should be able to reference a table with a schema set', function(done) {
var self = this var self = this
var sequelize = this.sequelize
var UserPub = this.sequelize.define('UserPub', { var UserPub = this.sequelize.define('UserPub', {
username: Sequelize.STRING username: Sequelize.STRING
...@@ -1463,14 +1462,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1463,14 +1462,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
var run = function() { var run = function() {
UserPub.sync({ force: true }).success(function() { UserPub.sync({ force: true }).success(function() {
ItemPub.sync({ force: true }).on('sql', function(sql) { ItemPub.sync({ force: true }).on('sql', _.after(2, function(sql) {
if (dialect === "postgres") { if (dialect === "postgres") {
expect(sql).to.match(/REFERENCES\s+"prefix"\."UserPubs" \("id"\)/) expect(sql).to.match(/REFERENCES\s+"prefix"\."UserPubs" \("id"\)/)
} else { } else {
expect(sql).to.match(/REFERENCES\s+`prefix\.UserPubs` \(`id`\)/) expect(sql).to.match(/REFERENCES\s+`prefix\.UserPubs` \(`id`\)/)
} }
done() done()
}) }))
}) })
} }
...@@ -1969,10 +1968,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1969,10 +1968,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
str: { type: Sequelize.STRING, unique: true } str: { type: Sequelize.STRING, unique: true }
}) })
uniqueTrue.sync({force: true}).on('sql', function(s) { uniqueTrue.sync({force: true}).on('sql', _.after(2, function(s) {
expect(s).to.match(/UNIQUE/) expect(s).to.match(/UNIQUE/)
done() done()
}) }))
}) })
it("should not set unique when unique is false", function(done) { it("should not set unique when unique is false", function(done) {
...@@ -1981,10 +1980,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1981,10 +1980,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
str: { type: Sequelize.STRING, unique: false } str: { type: Sequelize.STRING, unique: false }
}) })
uniqueFalse.sync({force: true}).on('sql', function(s) { uniqueFalse.sync({force: true}).on('sql', _.after(2, function(s) {
expect(s).not.to.match(/UNIQUE/) expect(s).not.to.match(/UNIQUE/)
done() done()
}) }))
}) })
it("should not set unique when unique is unset", function(done) { it("should not set unique when unique is unset", function(done) {
...@@ -1993,10 +1992,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1993,10 +1992,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
str: { type: Sequelize.STRING } str: { type: Sequelize.STRING }
}) })
uniqueUnset.sync({force: true}).on('sql', function(s) { uniqueUnset.sync({force: true}).on('sql', _.after(2, function(s) {
expect(s).not.to.match(/UNIQUE/) expect(s).not.to.match(/UNIQUE/)
done() done()
}) }))
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!