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

Commit c56a9afe by maximeCony

For the paranoidClause function, prevent that deletedAt is overwritten when the …

…where option is an array
1 parent b3b879b9
Showing with 12 additions and 2 deletions
...@@ -1191,17 +1191,27 @@ module.exports = (function() { ...@@ -1191,17 +1191,27 @@ module.exports = (function() {
options.where = options.where || {} options.where = options.where || {}
var deletedAtCol = Utils._.underscoredIf(this.options.deletedAt, this.options.underscored) var deletedAtCol = Utils._.underscoredIf(this.options.deletedAt, this.options.underscored)
, quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(deletedAtCol)
// 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[deletedAtCol]) { if (!!options.where[deletedAtCol]) {
return options return options
} }
if(this.tableName) {
quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(this.tableName) + '.' + quoteIdentifiedDeletedAtCol
}
if (typeof options.where === "string") { if (typeof options.where === "string") {
options.where += ' AND ' + this.QueryInterface.quoteIdentifier(deletedAtCol) + ' IS NULL ' options.where += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL '
} }
else if (Array.isArray(options.where)) { else if (Array.isArray(options.where)) {
options.where[0] += ' AND ' + this.QueryInterface.quoteIdentifier(deletedAtCol) + ' IS NULL '
// Don't overwrite our explicit deletedAt search value if we provide one
if(options.where[0].indexOf(deletedAtCol) !== -1) {
return options
}
options.where[0] += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL '
} else { } else {
options.where[deletedAtCol] = null options.where[deletedAtCol] = null
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!