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

Commit 0d8dad41 by José Moreira

Paranoid on include

1 parent d0f998a0
Showing with 31 additions and 25 deletions
...@@ -1573,39 +1573,45 @@ module.exports = (function() { ...@@ -1573,39 +1573,45 @@ module.exports = (function() {
// private // private
var paranoidClause = function(options) { var paranoidClause = function ( options ) {
if (this.options.paranoid === true) { if ( ! this.options.paranoid ) return options || {};
options = options || {}
options.where = options.where || {}
var deletedAtCol = this._timestampAttributes.deletedAt options = options || {}
, quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(deletedAtCol) options.where = options.where || {}
// Don't overwrite our explicit deletedAt search value if we provide one var deletedAtCol = this._timestampAttributes.deletedAt
if (!!options.where[deletedAtCol]) { , quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(deletedAtCol)
return options
}
if(this.name || this.tableName) { // Don't overwrite our explicit deletedAt search value if we provide one
quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(this.name || this.tableName) + '.' + quoteIdentifiedDeletedAtCol if (!!options.where[deletedAtCol]) {
} return options
}
if (typeof options.where === "string") { if(this.name || this.tableName) {
options.where += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL ' quoteIdentifiedDeletedAtCol = this.QueryInterface.quoteIdentifier(this.name || this.tableName) + '.' + quoteIdentifiedDeletedAtCol
} }
else if (Array.isArray(options.where)) {
// Don't overwrite our explicit deletedAt search value if we provide one if (typeof options.where === "string") {
if(options.where[0].indexOf(deletedAtCol) !== -1) { options.where += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL '
return options }
} else if (Array.isArray(options.where)) {
options.where[0] += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL '
} else { // Don't overwrite our explicit deletedAt search value if we provide one
options.where[deletedAtCol] = null if(options.where[0].indexOf(deletedAtCol) !== -1) {
return options
} }
options.where[0] += ' AND ' + quoteIdentifiedDeletedAtCol + ' IS NULL '
} else {
options.where[deletedAtCol] = null
} }
return options // Apply on each include
if ( options.include && options.include.length )
for( var i in options.include )
if( typeof options.include[i] == 'object' )
paranoidClause.call( options.include[i].daoFactory, options.include[i] );
return options;
} }
var addOptionalClassMethods = function() { var addOptionalClassMethods = function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!