ModelQuery: fix is null / is not null checks

This commit is contained in:
Alice Gaudon 2020-07-27 10:56:43 +02:00
parent 2bbe4db5fe
commit 8746ad2ea3

View File

@ -263,7 +263,7 @@ class FieldValue {
} }
public toString(first: boolean = true): string { 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 { protected get test(): string {
@ -299,6 +299,13 @@ class WhereFieldValue extends FieldValue {
} }
protected get test(): string { 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; return this._test;
} }
} }