odata-query
Advanced tools
Comparing version 5.4.0 to 5.4.1
@@ -177,35 +177,39 @@ 'use strict'; | ||
} else if (value instanceof Object) { | ||
var operators = Object.keys(value); | ||
operators.forEach(function (op) { | ||
if (COMPARISON_OPERATORS.indexOf(op) !== -1) { | ||
result.push(propName + ' ' + op + ' ' + handleValue(value[op])); | ||
} else if (LOGICAL_OPERATORS.indexOf(op) !== -1) { | ||
if (Array.isArray(value[op])) { | ||
result.push(value[op].map(function (v) { | ||
return '(' + buildFilter(v, propName) + ')'; | ||
}).join(' ' + op + ' ')); | ||
if ('type' in value) { | ||
result.push(propName + ' eq ' + handleValue(value)); | ||
} else { | ||
var operators = Object.keys(value); | ||
operators.forEach(function (op) { | ||
if (COMPARISON_OPERATORS.indexOf(op) !== -1) { | ||
result.push(propName + ' ' + op + ' ' + handleValue(value[op])); | ||
} else if (LOGICAL_OPERATORS.indexOf(op) !== -1) { | ||
if (Array.isArray(value[op])) { | ||
result.push(value[op].map(function (v) { | ||
return '(' + buildFilter(v, propName) + ')'; | ||
}).join(' ' + op + ' ')); | ||
} else { | ||
result.push('(' + buildFilter(value[op], propName) + ')'); | ||
} | ||
} else if (COLLECTION_OPERATORS.indexOf(op) !== -1) { | ||
var lambaParameter = filterKey[0].toLowerCase(); | ||
var filter = buildFilter(value[op], lambaParameter); | ||
if (filter !== undefined) { | ||
// Do not apply collection filter if undefined (ex. ignore `Foo: { any: {} }`) | ||
result.push(propName + '/' + op + '(' + lambaParameter + ':' + filter + ')'); | ||
} | ||
} else if (op === 'in') { | ||
// Convert `{ Prop: { in: [1,2,3] } }` to `(Prop eq 1 or Prop eq 2 or Prop eq 3)` | ||
result.push('(' + value[op].map(function (v) { | ||
return propName + ' eq ' + handleValue(v); | ||
}).join(' or ') + ')'); | ||
} else if (BOOLEAN_FUNCTIONS.indexOf(op) !== -1) { | ||
// Simple boolean functions (startswith, endswith, contains) | ||
result.push(op + '(' + propName + ',' + handleValue(value[op]) + ')'); | ||
} else { | ||
result.push('(' + buildFilter(value[op], propName) + ')'); | ||
// Nested property | ||
result.push(buildFilter(value, propName)); | ||
} | ||
} else if (COLLECTION_OPERATORS.indexOf(op) !== -1) { | ||
var lambaParameter = filterKey[0].toLowerCase(); | ||
var filter = buildFilter(value[op], lambaParameter); | ||
if (filter !== undefined) { | ||
// Do not apply collection filter if undefined (ex. ignore `Foo: { any: {} }`) | ||
result.push(propName + '/' + op + '(' + lambaParameter + ':' + filter + ')'); | ||
} | ||
} else if (op === 'in') { | ||
// Convert `{ Prop: { in: [1,2,3] } }` to `(Prop eq 1 or Prop eq 2 or Prop eq 3)` | ||
result.push('(' + value[op].map(function (v) { | ||
return propName + ' eq ' + handleValue(v); | ||
}).join(' or ') + ')'); | ||
} else if (BOOLEAN_FUNCTIONS.indexOf(op) !== -1) { | ||
// Simple boolean functions (startswith, endswith, contains) | ||
result.push(op + '(' + propName + ',' + handleValue(value[op]) + ')'); | ||
} else { | ||
// Nested property | ||
result.push(buildFilter(value, propName)); | ||
} | ||
}); | ||
}); | ||
} | ||
} else if (value === undefined) { | ||
@@ -212,0 +216,0 @@ // Ignore/omit filter if value is `undefined` |
{ | ||
"name": "odata-query", | ||
"version": "5.4.0", | ||
"version": "5.4.1", | ||
"author": "Sean Lynch <techniq35@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27594
347