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

Commit a663c549 by markvp Committed by GitHub

fix(query-generator): use `AND` in sql for `not`/`between` (#13043)

1 parent 97ba2422
...@@ -2167,7 +2167,9 @@ class QueryGenerator { ...@@ -2167,7 +2167,9 @@ class QueryGenerator {
model: factory model: factory
}); });
} }
if (typeof value === 'boolean') { if ([this.OperatorMap[Op.between], this.OperatorMap[Op.notBetween]].includes(smth.comparator)) {
value = `${this.escape(value[0])} AND ${this.escape(value[1])}`;
} else if (typeof value === 'boolean') {
value = this.booleanValue(value); value = this.booleanValue(value);
} else { } else {
value = this.escape(value); value = this.escape(value);
......
...@@ -1263,5 +1263,13 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -1263,5 +1263,13 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
current.where(current.fn('lower', current.col('name')), null)], { current.where(current.fn('lower', current.col('name')), null)], {
default: '(SUM([hours]) > 0 AND lower([name]) IS NULL)' default: '(SUM([hours]) > 0 AND lower([name]) IS NULL)'
}); });
testsql(current.where(current.col('hours'), Op.between, [0, 5]), {
default: '[hours] BETWEEN 0 AND 5'
});
testsql(current.where(current.col('hours'), Op.notBetween, [0, 5]), {
default: '[hours] NOT BETWEEN 0 AND 5'
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!