From 4776eaaa18b9394990365c3b1674690777b5462d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 24 Sep 2024 17:59:08 +0530 Subject: [PATCH] fix: skip trimming options while applying filter (#9542) --- packages/nocodb/src/db/conditionV2.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/db/conditionV2.ts b/packages/nocodb/src/db/conditionV2.ts index 746b3fcbe8..7aa5285080 100644 --- a/packages/nocodb/src/db/conditionV2.ts +++ b/packages/nocodb/src/db/conditionV2.ts @@ -927,7 +927,14 @@ const parseConditionV2 = async ( { // Condition for filter, without negation const condition = (builder: Knex.QueryBuilder) => { - const items = val?.split(',').map((item) => item.trim()); + let items = val?.split(','); + // remove trailing space if database is MySQL and datatype is enum/set + if ( + ['mysql2', 'mysql'].includes(knex.clientType()) && + ['enum', 'set'].includes(column.dt?.toLowerCase()) + ) { + items = items.map((item) => item.trimEnd()); + } for (let i = 0; i < items?.length; i++) { let sql; const bindings = [field, `%,${items[i]},%`];