From 65694644c3349b13646958f542ba81ab46800086 Mon Sep 17 00:00:00 2001 From: pofider Date: Mon, 30 Jan 2023 15:35:05 +0100 Subject: [PATCH] add support to ne --- lib/queryTransform.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/queryTransform.js b/lib/queryTransform.js index 6d976cc..5bd159b 100644 --- a/lib/queryTransform.js +++ b/lib/queryTransform.js @@ -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())