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

Commit 51a1b08d by Ryan Pon

better fix for paranoidClause failing complex wheres

1 parent 8683d792
Showing with 22 additions and 3 deletions
...@@ -1584,9 +1584,11 @@ module.exports = (function() { ...@@ -1584,9 +1584,11 @@ module.exports = (function() {
// of string-likes/Dates or an array with objects, hashes, or other // of string-likes/Dates or an array with objects, hashes, or other
// complex data types // complex data types
if (Utils.canTreatArrayAsAnd(options.where)) { if (Utils.canTreatArrayAsAnd(options.where)) {
// TODO: This is simplifying this case greatly. We actually need all // smth, tableName, factory, options, prepend
// the logic from QueryGenerator.getWhereConditions in order to var whereClause = this.QueryGenerator.getWhereConditions(options.where, this.getTableName(), this, options);
// properly decide what to do here. if (whereClause.indexOf(deletedAtCol) !== -1) {
return options;
}
var whereObj = {}; var whereObj = {};
whereObj[quoteIdentifiedDeletedAtCol] = null; whereObj[quoteIdentifiedDeletedAtCol] = null;
options.where.push(whereObj); options.where.push(whereObj);
......
...@@ -2159,6 +2159,23 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -2159,6 +2159,23 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}).error(done) }).error(done)
}) })
it.only('should not overwrite a specified deletedAt (complex query)', function (done) {
this.User.findAll({
where: [
this.sequelize.or({ username: 'leia' }, { username: 'luke' }),
this.sequelize.and(
{ id: [1, 2, 3] },
this.sequelize.or({ deletedAt: null }, { deletedAt: { gt: new Date(0) } })
)
]
})
.then(function(res) {
expect(res).to.have.length(2)
done()
})
.catch(function(e) { done(e) })
})
}) })
if (dialect !== 'sqlite') { if (dialect !== 'sqlite') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!