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

Commit 6ec0abd1 by Jan Aagaard Meier

internals(and/or) Fix use of plain or and and internally for pg

1 parent 465aa4cb
Showing with 6 additions and 4 deletions
......@@ -1885,6 +1885,11 @@ var QueryGenerator = {
if (typeof value === 'string') {
return value;
}
if (_.isPlainObject(value) && _.size(value) === 1) {
key = Object.keys(value)[0];
value = _.values(value)[0];
}
}
if (value && value._isSequelizeMethod && !(key !== undefined && value instanceof Utils.fn)) {
......@@ -1899,19 +1904,16 @@ var QueryGenerator = {
return Utils.format(value, this.dialect);
}
}
// OR/AND/NOT grouping logic
if (key === '$or' || key === '$and' || key === '$not') {
binding = (key === '$or') ?' OR ' : ' AND ';
outerBinding = '';
if (key === '$not') outerBinding = 'NOT ';
if (Array.isArray(value)) {
value = value.map(function (item) {
var itemQuery = self.whereItemsQuery(item, options, ' AND ');
if ((Array.isArray(item) || _.isPlainObject(item)) &&_.size(item) > 1) {
if ((Array.isArray(item) || _.isPlainObject(item)) && _.size(item) > 1) {
itemQuery = '('+itemQuery+')';
}
return itemQuery;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!