From f2b224b964689ff9f296a594ca3cc9db041c93f1 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 2 Feb 2023 14:11:13 +0800 Subject: [PATCH] feat(nocodb): handle case sensitive case for mysql --- .../db/sql-data-mapper/lib/sql/conditionV2.ts | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index 2711fc881e..c09199258a 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -273,15 +273,29 @@ const parseConditionV2 = async ( let [field, val] = [_field, _val]; switch (filter.comparison_op) { case 'eq': - qb = qb.where(field, val); + if (qb?.client?.config?.client === 'mysql2') { + // mysql is case-insensitive, turn to case-sensitive + qb = qb.whereRaw('BINARY ?? = ?', [field, val]); + } else { + qb = qb.where(field, val); + } break; case 'neq': case 'not': - qb = qb.where((nestedQb) => { - nestedQb - .whereNot(field, val) - .orWhereNull(customWhereClause ? _val : _field); - }); + if (qb?.client?.config?.client === 'mysql2') { + // mysql is case-insensitive, turn to case-sensitive + qb = qb.where((nestedQb) => { + nestedQb + .whereRaw('BINARY ?? != ?', [field, val]) + .orWhereNull(customWhereClause ? _val : _field); + }); + } else { + qb = qb.where((nestedQb) => { + nestedQb + .whereNot(field, val) + .orWhereNull(customWhereClause ? _val : _field); + }); + } break; case 'like': if (!val) {