From 4933b34f6b5dfa960c2a830a8c74769d6712130a Mon Sep 17 00:00:00 2001 From: James Date: Tue, 22 Jun 2021 15:15:15 -0400 Subject: [PATCH] fix: parses incoming numbers through query string for use in where clauses --- src/mongoose/buildQuery.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mongoose/buildQuery.ts b/src/mongoose/buildQuery.ts index 1fa7f97ba09..1effc6fe58a 100644 --- a/src/mongoose/buildQuery.ts +++ b/src/mongoose/buildQuery.ts @@ -168,13 +168,22 @@ class ParamParser { } } let formattedValue = val; - if (schemaObject && schemaObject.type === Boolean && typeof val === 'string') { + + const schemaObjectType = schemaObject?.localized ? schemaObject?.type[this.locale].type : schemaObject?.type; + + if (schemaObject && schemaObjectType === Boolean && typeof val === 'string') { if (val.toLowerCase() === 'true') formattedValue = true; if (val.toLowerCase() === 'false') formattedValue = false; } + + if (schemaObject && schemaObjectType === Number && typeof val === 'string') { + formattedValue = Number(val); + } + if (schemaObject && schemaObject.ref && val === 'null') { formattedValue = null; } + if (operator && validOperators.includes(operator)) { switch (operator) { case 'greater_than_equal':