From 1d0e83134234b696759fa3c7dfa7ac75bc941bf1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 4 Jan 2024 13:19:19 +0000 Subject: [PATCH] feat: condition(created/updated time) --- packages/nocodb/src/db/conditionV2.ts | 37 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/nocodb/src/db/conditionV2.ts b/packages/nocodb/src/db/conditionV2.ts index f31a313b1a..76f318d7e9 100644 --- a/packages/nocodb/src/db/conditionV2.ts +++ b/packages/nocodb/src/db/conditionV2.ts @@ -550,7 +550,14 @@ const parseConditionV2 = async ( ? 'YYYY-MM-DD HH:mm:ss' : '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()); const dateFormatFromMeta = column?.meta?.date_format; if (dateFormatFromMeta && isDateMonthFormat(dateFormatFromMeta)) { @@ -661,7 +668,13 @@ const parseConditionV2 = async ( qb = qb.where(knex.raw('BINARY ?? = ?', [field, val])); } } else { - if (column.uidt === UITypes.DateTime) { + if ( + [ + UITypes.DateTime, + UITypes.CreateTime, + UITypes.LastModifiedTime, + ].includes(column.uidt) + ) { if (qb.client.config.client === 'pg') { qb = qb.where(knex.raw('??::date = ?', [field, val])); } else { @@ -945,9 +958,13 @@ const parseConditionV2 = async ( qb = qb.whereNull(customWhereClause || field); if ( !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, ''); } @@ -963,9 +980,13 @@ const parseConditionV2 = async ( qb = qb.whereNotNull(customWhereClause || field); if ( !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, ''); }