ModelQuery: fix array of values to string conversion

This commit is contained in:
Alice Gaudon 2020-08-28 15:40:58 +02:00
parent fed54b9483
commit 813e10c4c7

View File

@ -265,7 +265,9 @@ class FieldValue {
}
public toString(first: boolean = true): string {
return `${!first ? ',' : ''}${this.field}${this.test}${this.raw || this.value === null || this.value instanceof ModelQuery ? this.value : (Array.isArray(this.value) ? '(?)' : '?')}`;
const valueStr = this.raw || this.value === null || this.value instanceof ModelQuery ? this.value :
(Array.isArray(this.value) ? `(${'?'.repeat(this.value.length).split('').join(',')})` : '?');
return `${!first ? ',' : ''}${this.field}${this.test}${valueStr}`;
}
protected get test(): string {
@ -275,6 +277,7 @@ class FieldValue {
public get variables(): any[] {
if (this.value instanceof ModelQuery) return this.value.variables;
if (this.raw || this.value === null) return [];
if (Array.isArray(this.value)) return this.value;
return [this.value];
}
}