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

Commit 476b08be by Jozef Hartinger Committed by Sushant

fix(query-generator): allow Op as comparator in sequelize.where (#9124)

1 parent 5b6dae76
...@@ -1861,6 +1861,10 @@ const QueryGenerator = { ...@@ -1861,6 +1861,10 @@ const QueryGenerator = {
handleSequelizeMethod(smth, tableName, factory, options, prepend) { handleSequelizeMethod(smth, tableName, factory, options, prepend) {
let result; let result;
if (this.OperatorMap.hasOwnProperty(smth.comparator)) {
smth.comparator = this.OperatorMap[smth.comparator];
}
if (smth instanceof Utils.Where) { if (smth instanceof Utils.Where) {
let value = smth.logic; let value = smth.logic;
let key; let key;
......
...@@ -927,7 +927,7 @@ class Sequelize { ...@@ -927,7 +927,7 @@ class Sequelize {
* @see {@link Model.findAll} * @see {@link Model.findAll}
* *
* @param {Object} attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the POJO syntax * @param {Object} attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the POJO syntax
* @param {string} [comparator='='] * @param {String|Op} [comparator='=']
* @param {String|Object} logic The condition. Can be both a simply type, or a further condition (`or`, `and`, `.literal` etc.) * @param {String|Object} logic The condition. Can be both a simply type, or a further condition (`or`, `and`, `.literal` etc.)
* @alias condition * @alias condition
* @since v2.0.0-dev3 * @since v2.0.0-dev3
......
...@@ -1117,5 +1117,13 @@ suite(Support.getTestDialectTeaser('SQL'), () => { ...@@ -1117,5 +1117,13 @@ suite(Support.getTestDialectTeaser('SQL'), () => {
testsql(current.where(current.fn('lower', current.col('name')), null), { testsql(current.where(current.fn('lower', current.col('name')), null), {
default: 'lower([name]) IS NULL' default: 'lower([name]) IS NULL'
}); });
testsql(current.where(current.fn('SUM', current.col('hours')), '>', 0), {
default: 'SUM([hours]) > 0'
});
testsql(current.where(current.fn('SUM', current.col('hours')), current.Op.gt, 0), {
default: 'SUM([hours]) > 0'
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!