Browse Source

feat(nocodb): handle eq & neq cases for numerics

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

48
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

@ -274,8 +274,22 @@ const parseConditionV2 = async (
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]);
if (
[
UITypes.Duration,
UITypes.Currency,
UITypes.Percent,
UITypes.Number,
UITypes.Decimal,
UITypes.Rating,
UITypes.Rollup,
].includes(column.uidt)
) {
qb = qb.where(field, val);
} else {
// mysql is case-insensitive for strings, turn to case-sensitive
qb = qb.whereRaw('BINARY ?? = ?', [field, val]);
}
} else {
qb = qb.where(field, val);
}
@ -283,12 +297,30 @@ const parseConditionV2 = async (
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);
});
if (
[
UITypes.Duration,
UITypes.Currency,
UITypes.Percent,
UITypes.Number,
UITypes.Decimal,
UITypes.Rating,
UITypes.Rollup,
].includes(column.uidt)
) {
qb = qb.where((nestedQb) => {
nestedQb
.whereNot(field, val)
.orWhereNull(customWhereClause ? _val : _field);
});
} else {
// mysql is case-insensitive for strings, turn to case-sensitive
qb = qb.where((nestedQb) => {
nestedQb
.whereRaw('BINARY ?? != ?', [field, val])
.orWhereNull(customWhereClause ? _val : _field);
});
}
} else {
qb = qb.where((nestedQb) => {
nestedQb

Loading…
Cancel
Save