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

Commit 1fac401a by Jan Aagaard Meier

Merge pull request #1036 from josemando/master

Problem on v1.7.0-beta.1 using MySQL with paranoid and underscored enabled
2 parents 72bc6d15 55749fa0
Showing with 24 additions and 4 deletions
...@@ -1109,18 +1109,20 @@ module.exports = (function() { ...@@ -1109,18 +1109,20 @@ module.exports = (function() {
options = options || {} options = options || {}
options.where = options.where || {} options.where = options.where || {}
var deletedAtCol = Utils._.underscoredIf(this.options.deletedAt, this.options.underscored)
// Don't overwrite our explicit deletedAt search value if we provide one // Don't overwrite our explicit deletedAt search value if we provide one
if (!!options.where[this.options.deletedAt]) { if (!!options.where[deletedAtCol]) {
return options return options
} }
if (typeof options.where === "string") { if (typeof options.where === "string") {
options.where += ' AND ' + this.QueryInterface.quoteIdentifier(this.options.deletedAt) + ' IS NULL ' options.where += ' AND ' + this.QueryInterface.quoteIdentifier(deletedAtCol) + ' IS NULL '
} }
else if (Array.isArray(options.where)) { else if (Array.isArray(options.where)) {
options.where[0] += ' AND ' + this.QueryInterface.quoteIdentifier(this.options.deletedAt) + ' IS NULL ' options.where[0] += ' AND ' + this.QueryInterface.quoteIdentifier(deletedAtCol) + ' IS NULL '
} else { } else {
options.where[this.options.deletedAt] = null options.where[deletedAtCol] = null
} }
} }
......
...@@ -227,6 +227,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -227,6 +227,24 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
}) })
it('should work with both paranoid and underscored being true', function(done) {
var UserTable = this.sequelize.define('UserCol', {
aNumber: Sequelize.INTEGER
}, {
paranoid: true,
underscored: true
})
UserTable.sync({force: true}).success(function() {
UserTable.create({aNumber: 30}).success(function(user) {
UserTable.count().success(function(c) {
expect(c).to.equal(1)
done()
})
})
})
})
}) })
describe('build', function() { describe('build', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!