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

Commit 7f065c34 by Paulo R Lopes Committed by Sushant

fix(query-generator): add spaces around comparator (#9427)

1 parent addceb64
...@@ -1918,7 +1918,7 @@ class QueryGenerator { ...@@ -1918,7 +1918,7 @@ class QueryGenerator {
if (value && value instanceof Utils.SequelizeMethod) { if (value && value instanceof Utils.SequelizeMethod) {
value = this.getWhereConditions(value, tableName, factory, options, prepend); value = this.getWhereConditions(value, tableName, factory, options, prepend);
result = value === 'NULL' ? key + ' IS NULL' : [key, value].join(smth.comparator); result = value === 'NULL' ? key + ' IS NULL' : [key, value].join(' ' + smth.comparator + ' ');
} else if (_.isPlainObject(value)) { } else if (_.isPlainObject(value)) {
result = this.whereItemQuery(smth.attribute, value, { result = this.whereItemQuery(smth.attribute, value, {
model: factory model: factory
......
...@@ -86,6 +86,12 @@ describe('QueryGenerator', () => { ...@@ -86,6 +86,12 @@ describe('QueryGenerator', () => {
expect(() => QG.whereItemQuery('test', {$in: [4]})) expect(() => QG.whereItemQuery('test', {$in: [4]}))
.to.throw('Invalid value { \'$in\': [ 4 ] }'); .to.throw('Invalid value { \'$in\': [ 4 ] }');
}); });
it('should correctly parse sequelize.where with .fn as logic', function() {
const QG = getAbstractQueryGenerator(this.sequelize);
QG.handleSequelizeMethod(this.sequelize.where(this.sequelize.col('foo'), 'LIKE', this.sequelize.col('bar')))
.should.be.equal('foo LIKE bar');
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!