|
|
|
@ -725,7 +725,7 @@ const parseConditionV2 = async (
|
|
|
|
|
].includes(column.uidt) |
|
|
|
|
) { |
|
|
|
|
if (qb.client.config.client === 'pg') { |
|
|
|
|
// todo: enbale back if group by date required custom implementation
|
|
|
|
|
// todo: enable back if group by date required custom implementation
|
|
|
|
|
// if ((filter as any).groupby)
|
|
|
|
|
// qb = qb.where(knex.raw('??::timestamp = ?', [field, val]));
|
|
|
|
|
// else
|
|
|
|
@ -899,6 +899,15 @@ const parseConditionV2 = async (
|
|
|
|
|
case 'gt': |
|
|
|
|
{ |
|
|
|
|
const gt_op = customWhereClause ? '<' : '>'; |
|
|
|
|
// If the column is a datetime and the client is pg and the value has a timezone offset at the end
|
|
|
|
|
// then we need to convert the value to timestamptz before comparing
|
|
|
|
|
if ( |
|
|
|
|
column.uidt === UITypes.DateTime && |
|
|
|
|
qb.client.config.client === 'pg' && |
|
|
|
|
val.match(/[+-]\d{2}:\d{2}$/) |
|
|
|
|
) { |
|
|
|
|
qb.where(field, gt_op, knex.raw('?::timestamptz', [val])); |
|
|
|
|
} else { |
|
|
|
|
qb = qb.where(field, gt_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
// unset rating is considered as NULL
|
|
|
|
@ -907,11 +916,21 @@ const parseConditionV2 = async (
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'ge': |
|
|
|
|
case 'gte': |
|
|
|
|
{ |
|
|
|
|
const ge_op = customWhereClause ? '<=' : '>='; |
|
|
|
|
// If the column is a datetime and the client is pg and the value has a timezone offset at the end
|
|
|
|
|
// then we need to convert the value to timestamptz before comparing
|
|
|
|
|
if ( |
|
|
|
|
column.uidt === UITypes.DateTime && |
|
|
|
|
qb.client.config.client === 'pg' && |
|
|
|
|
val.match(/[+-]\d{2}:\d{2}$/) |
|
|
|
|
) { |
|
|
|
|
qb.where(field, ge_op, knex.raw('?::timestamptz', [val])); |
|
|
|
|
} else { |
|
|
|
|
qb = qb.where(field, ge_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
// unset rating is considered as NULL
|
|
|
|
@ -920,10 +939,20 @@ const parseConditionV2 = async (
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'lt': |
|
|
|
|
{ |
|
|
|
|
const lt_op = customWhereClause ? '>' : '<'; |
|
|
|
|
// If the column is a datetime and the client is pg and the value has a timezone offset at the end
|
|
|
|
|
// then we need to convert the value to timestamptz before comparing
|
|
|
|
|
if ( |
|
|
|
|
column.uidt === UITypes.DateTime && |
|
|
|
|
qb.client.config.client === 'pg' && |
|
|
|
|
val.match(/[+-]\d{2}:\d{2}$/) |
|
|
|
|
) { |
|
|
|
|
qb.where(field, lt_op, knex.raw('?::timestamptz', [val])); |
|
|
|
|
} else { |
|
|
|
|
qb = qb.where(field, lt_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
// unset number is considered as NULL
|
|
|
|
@ -932,12 +961,22 @@ const parseConditionV2 = async (
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'le': |
|
|
|
|
case 'lte': |
|
|
|
|
{ |
|
|
|
|
const le_op = customWhereClause ? '>=' : '<='; |
|
|
|
|
// If the column is a datetime and the client is pg and the value has a timezone offset at the end
|
|
|
|
|
// then we need to convert the value to timestamptz before comparing
|
|
|
|
|
if ( |
|
|
|
|
column.uidt === UITypes.DateTime && |
|
|
|
|
qb.client.config.client === 'pg' && |
|
|
|
|
val.match(/[+-]\d{2}:\d{2}$/) |
|
|
|
|
) { |
|
|
|
|
qb.where(field, le_op, knex.raw('?::timestamptz', [val])); |
|
|
|
|
} else { |
|
|
|
|
qb = qb.where(field, le_op, val); |
|
|
|
|
if (column.uidt === UITypes.Rating) { |
|
|
|
|
// unset number is considered as NULL
|
|
|
|
@ -946,6 +985,7 @@ const parseConditionV2 = async (
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'in': |
|
|
|
|
qb = qb.whereIn( |
|
|
|
|