|
|
|
@ -280,6 +280,12 @@ const parseConditionV2 = async (
|
|
|
|
|
// val cannot be empty for non-is & non-isnot filters
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
// convert to number
|
|
|
|
|
val = +val; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (filter.comparison_op) { |
|
|
|
|
case 'eq': |
|
|
|
|
if (qb?.client?.config?.client === 'mysql2') { |
|
|
|
@ -302,6 +308,10 @@ const parseConditionV2 = async (
|
|
|
|
|
} else { |
|
|
|
|
qb = qb.where(field, val); |
|
|
|
|
} |
|
|
|
|
if (column.uidt === UITypes.Rating && val === 0) { |
|
|
|
|
// unset rating is considered as NULL
|
|
|
|
|
qb = qb.orWhereNull(field); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'neq': |
|
|
|
|
case 'not': |
|
|
|
@ -313,7 +323,6 @@ const parseConditionV2 = async (
|
|
|
|
|
UITypes.Percent, |
|
|
|
|
UITypes.Number, |
|
|
|
|
UITypes.Decimal, |
|
|
|
|
UITypes.Rating, |
|
|
|
|
UITypes.Rollup, |
|
|
|
|
].includes(column.uidt) |
|
|
|
|
) { |
|
|
|
@ -322,12 +331,20 @@ const parseConditionV2 = async (
|
|
|
|
|
.whereNot(field, val) |
|
|
|
|
.orWhereNull(customWhereClause ? _val : _field); |
|
|
|
|
}); |
|
|
|
|
} else if (column.uidt === UITypes.Rating) { |
|
|
|
|
// unset rating is considered as NULL
|
|
|
|
|
if (val === 0) { |
|
|
|
|
qb = qb.whereNot(field, val).whereNotNull(field); |
|
|
|
|
} else { |
|
|
|
|
qb = qb.whereNot(field, val).orWhereNull(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); |
|
|
|
|
nestedQb.whereRaw('BINARY ?? != ?', [field, val]); |
|
|
|
|
if (column.uidt !== UITypes.Rating) { |
|
|
|
|
nestedQb.orWhereNull(customWhereClause ? _val : _field); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -431,11 +448,23 @@ const parseConditionV2 = async (
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'gt': |
|
|
|
|
qb = qb.where(field, customWhereClause ? '<' : '>', val); |
|
|
|
|
const gt_op = customWhereClause ? '<' : '>'; |
|
|
|
|
qb = qb.where(field, gt_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
if (gt_op === '<' && val > 0) { |
|
|
|
|
qb = qb.orWhereNull(field); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'ge': |
|
|
|
|
case 'gte': |
|
|
|
|
qb = qb.where(field, customWhereClause ? '<=' : '>=', val); |
|
|
|
|
const ge_op = customWhereClause ? '<=' : '>='; |
|
|
|
|
qb = qb.where(field, ge_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
if (ge_op === '<=' || (ge_op === '>=' && val === 0)) { |
|
|
|
|
qb = qb.orWhereNull(field); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'in': |
|
|
|
|
qb = qb.whereIn( |
|
|
|
@ -474,11 +503,23 @@ const parseConditionV2 = async (
|
|
|
|
|
qb = qb.whereNot(customWhereClause || field, false); |
|
|
|
|
break; |
|
|
|
|
case 'lt': |
|
|
|
|
qb = qb.where(field, customWhereClause ? '>' : '<', val); |
|
|
|
|
const lt_op = customWhereClause ? '>' : '<'; |
|
|
|
|
qb = qb.where(field, lt_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
if (lt_op === '<' && val > 0) { |
|
|
|
|
qb = qb.orWhereNull(field); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'le': |
|
|
|
|
case 'lte': |
|
|
|
|
qb = qb.where(field, customWhereClause ? '>=' : '<=', val); |
|
|
|
|
const le_op = customWhereClause ? '>=' : '<='; |
|
|
|
|
qb = qb.where(field, le_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
if (le_op === '<=' || (le_op === '>=' && val === 0)) { |
|
|
|
|
qb = qb.orWhereNull(field); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'empty': |
|
|
|
|
if (column.uidt === UITypes.Formula) { |
|
|
|
|