From 813e10c4c7b3b51cf3b69e76a7513e837a47753c Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Fri, 28 Aug 2020 15:40:58 +0200 Subject: [PATCH] ModelQuery: fix array of values to string conversion --- src/db/ModelQuery.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/db/ModelQuery.ts b/src/db/ModelQuery.ts index 883252c..504fadf 100644 --- a/src/db/ModelQuery.ts +++ b/src/db/ModelQuery.ts @@ -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]; } }