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

Commit 3397b237 by Michael McCabe Committed by Jan Aagaard Meier

fix(query-generator): Op.ne check with null value is not comparing with comparator

* test(query-generator.test): Added failing test to prove Op.is with null value produces wrong SQL

issue 8816

* fix(query-generator): Op.ne check with null value is not comparing with comparator, this is catching

fix issue #8816
1 parent d1f5618a
......@@ -2389,7 +2389,7 @@ const QueryGenerator = {
if (value === null && comparator === this.OperatorMap[Op.eq]) {
return this._joinKeyValue(key, this.escape(value, field, escapeOptions), this.OperatorMap[Op.is], options.prefix);
} else if (value === null && this.OperatorMap[Op.ne]) {
} else if (value === null && comparator === this.OperatorMap[Op.ne]) {
return this._joinKeyValue(key, this.escape(value, field, escapeOptions), this.OperatorMap[Op.not], options.prefix);
}
......
......@@ -14,6 +14,9 @@ describe('QueryGenerator', () => {
QG.whereItemQuery(Op.and, [{test: {[Op.between]: [2, 5]}}, {test: {[Op.ne]: 3}}, {test: {[Op.not]: 4}}])
.should.be.equal('(test BETWEEN 2 AND 5 AND test != 3 AND test != 4)');
QG.whereItemQuery(Op.or, [{test: {[Op.is]: null}}, {testSame: {[Op.eq]: null}}])
.should.be.equal('(test IS NULL OR testSame IS NULL)');
});
it('should not parse any strings as aliases operators', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!