Skip to content

Commit

Permalink
add support to ne
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Jan 30, 2023
1 parent d656808 commit 6569464
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/queryTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ Node.prototype.transform = function () {
this._prop(result, this.left, { $gte: this.right.value })
}

if (this.type === 'ne' && this.right.type === 'literal') {
// odata parser returns ['null', ''] for a filter with "field eq null"
// we handle the case by fixing the query in case this happens
if (
Array.isArray(this.right.value) &&
this.right.value.length === 2 &&
this.right.value[0] === 'null' &&
this.right.value[1] === ''
) {
this._prop(result, this.left, { $ne: null })
} else {
this._prop(result, this.left, { $ne: this.right.value })
}
}

if (this.type === 'and') {
result.$and = result.$and || []
result.$and.push(new Node(this.left.type, this.left.left, this.left.right, this.func, this.args).transform())
Expand Down

0 comments on commit 6569464

Please sign in to comment.