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

Commit 2f4ed327 by Mick Hansen

fix(includes): better support for merging paranoid where and subquery creating include where

1 parent a3ec0afb
......@@ -1112,12 +1112,20 @@ module.exports = (function() {
limit: 1
}, include.model);
options.where['__' + as] = self.sequelize.asIs([
var subQueryWhere = self.sequelize.asIs([
'(',
$query.replace(/\;$/, ""),
')',
'IS NOT NULL'
].join(' '));
if (options.where instanceof Utils.and) {
options.where.args.push(subQueryWhere);
} else if (Utils._.isPlainObject(options.where)) {
options.where['__' + as] = subQueryWhere;
} else {
options.where = new Utils.and(options.where, subQueryWhere);
}
}
// Generate join SQL
......
......@@ -1955,7 +1955,7 @@ describe(Support.getTestDialectTeaser('Include'), function() {
});
});
it('should work with paranoid, a main record where, an include where, and a limit', function (done) {
it('should work with paranoid, a main record where, an include where, and a limit', function () {
var Post = this.sequelize.define('post', {
date: DataTypes.DATE,
"public": DataTypes.BOOLEAN
......@@ -1995,7 +1995,6 @@ describe(Support.getTestDialectTeaser('Include'), function() {
]
}).then(function (posts) {
expect(posts.length).to.equal(2);
done();
});
});
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!