From 40a20baa2744a6b22809a1acf09d776d7e7f1ae3 Mon Sep 17 00:00:00 2001 From: Oreilles Date: Tue, 19 Jan 2021 08:46:02 +0100 Subject: [PATCH] Fix wrong number casting in query --- api/src/utils/apply-query.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/utils/apply-query.ts b/api/src/utils/apply-query.ts index 2acfd8a9bb..e9b75d909d 100644 --- a/api/src/utils/apply-query.ts +++ b/api/src/utils/apply-query.ts @@ -51,7 +51,8 @@ export default async function applyQuery( if (['text', 'string'].includes(column.localType)) { this.orWhereRaw(`LOWER(??) LIKE ?`, [column.column_name, `%${query.search!.toLowerCase()}%`]); } else if (['bigInteger', 'integer', 'decimal', 'float'].includes(column.localType)) { - this.orWhere({ [column.column_name]: Number(query.search!) }); + const number = Number(query.search!); + if (!isNaN(number)) this.orWhere({ [column.column_name]: number }); } else if (column.localType === 'uuid' && validate(query.search!)) { this.orWhere({ [column.column_name]: query.search! }); }