Browse Source

feat(nocodb): handle case sensitive case for mysql

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

26
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) {

Loading…
Cancel
Save