Browse Source

feat: condition(created/updated time)

pull/7304/head
Pranav C 9 months ago
parent
commit
1d0e831342
  1. 37
      packages/nocodb/src/db/conditionV2.ts

37
packages/nocodb/src/db/conditionV2.ts

@ -550,7 +550,14 @@ const parseConditionV2 = async (
? 'YYYY-MM-DD HH:mm:ss' ? 'YYYY-MM-DD HH:mm:ss'
: 'YYYY-MM-DD HH:mm:ssZ'; : 'YYYY-MM-DD HH:mm:ssZ';
if ([UITypes.Date, UITypes.DateTime].includes(column.uidt)) { if (
[
UITypes.Date,
UITypes.DateTime,
UITypes.CreateTime,
UITypes.LastModifiedTime,
].includes(column.uidt)
) {
let now = dayjs(new Date()); let now = dayjs(new Date());
const dateFormatFromMeta = column?.meta?.date_format; const dateFormatFromMeta = column?.meta?.date_format;
if (dateFormatFromMeta && isDateMonthFormat(dateFormatFromMeta)) { if (dateFormatFromMeta && isDateMonthFormat(dateFormatFromMeta)) {
@ -661,7 +668,13 @@ const parseConditionV2 = async (
qb = qb.where(knex.raw('BINARY ?? = ?', [field, val])); qb = qb.where(knex.raw('BINARY ?? = ?', [field, val]));
} }
} else { } else {
if (column.uidt === UITypes.DateTime) { if (
[
UITypes.DateTime,
UITypes.CreateTime,
UITypes.LastModifiedTime,
].includes(column.uidt)
) {
if (qb.client.config.client === 'pg') { if (qb.client.config.client === 'pg') {
qb = qb.where(knex.raw('??::date = ?', [field, val])); qb = qb.where(knex.raw('??::date = ?', [field, val]));
} else { } else {
@ -945,9 +958,13 @@ const parseConditionV2 = async (
qb = qb.whereNull(customWhereClause || field); qb = qb.whereNull(customWhereClause || field);
if ( if (
!isNumericCol(column.uidt) && !isNumericCol(column.uidt) &&
![UITypes.Date, UITypes.DateTime, UITypes.Time].includes( ![
column.uidt, UITypes.Date,
) UITypes.CreateTime,
UITypes.LastModifiedTime,
UITypes.DateTime,
UITypes.Time,
].includes(column.uidt)
) { ) {
qb = qb.orWhere(field, ''); qb = qb.orWhere(field, '');
} }
@ -963,9 +980,13 @@ const parseConditionV2 = async (
qb = qb.whereNotNull(customWhereClause || field); qb = qb.whereNotNull(customWhereClause || field);
if ( if (
!isNumericCol(column.uidt) && !isNumericCol(column.uidt) &&
![UITypes.Date, UITypes.DateTime, UITypes.Time].includes( ![
column.uidt, UITypes.Date,
) UITypes.DateTime,
UITypes.CreateTime,
UITypes.LastModifiedTime,
UITypes.Time,
].includes(column.uidt)
) { ) {
qb = qb.whereNot(field, ''); qb = qb.whereNot(field, '');
} }

Loading…
Cancel
Save