Fix wrong number casting in query

This commit is contained in:
Oreilles
2021-01-19 08:46:02 +01:00
parent ba0cfd0dcf
commit 40a20baa27

View File

@@ -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! });
}