Browse Source

feat(nocodb): handle case sensitive case for mysql

pull/5106/head
Wing-Kam Wong 2 years ago
parent
commit
f2b224b964
  1. 14
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

14
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':
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':
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) {

Loading…
Cancel
Save