From 8746ad2ea34b48a29357ac491398e9d6d3ed99bc Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Mon, 27 Jul 2020 10:56:43 +0200 Subject: [PATCH] ModelQuery: fix is null / is not null checks --- src/db/ModelQuery.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/db/ModelQuery.ts b/src/db/ModelQuery.ts index 0708c02..b67f1d1 100644 --- a/src/db/ModelQuery.ts +++ b/src/db/ModelQuery.ts @@ -263,7 +263,7 @@ class FieldValue { } public toString(first: boolean = true): string { - return `${!first ? ',' : ''}${this.field}${this.test}${this.raw || this.value instanceof ModelQuery ? this.value : (Array.isArray(this.value) ? '(?)' : '?')}`; + return `${!first ? ',' : ''}${this.field}${this.test}${this.raw || this.value === null || this.value instanceof ModelQuery ? this.value : (Array.isArray(this.value) ? '(?)' : '?')}`; } protected get test(): string { @@ -299,6 +299,13 @@ class WhereFieldValue extends FieldValue { } protected get test(): string { + if (this.value === null) { + if (this._test === WhereTest.EQ) { + return ' IS '; + } else if (this._test === WhereTest.NE) { + return ' IS NOT '; + } + } return this._test; } } \ No newline at end of file