From 2860fa6546ec8fee1b77c4043b51a62f40e23ee1 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 27 Feb 2023 18:10:40 +0800 Subject: [PATCH] refactor(nocodb): turn `val` in dayjs object format to string --- .../src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index 41749ce6e0..04cdc11edd 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -280,7 +280,6 @@ const parseConditionV2 = async ( qb?.client?.config?.client === 'mysql2' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'; - let convertDayJsObjToStr = true; // handle sub operation switch (filter.comparison_sub_op) { case 'today': @@ -314,7 +313,6 @@ const parseConditionV2 = async ( break; case 'exactDate': if (!val) return; - convertDayJsObjToStr = false; break; // sub-ops for `isWithin` comparison case 'pastWeek': @@ -337,17 +335,15 @@ const parseConditionV2 = async ( break; case 'pastNumberOfDays': if (!val) return; - convertDayJsObjToStr = false; val = now.add(-val, 'day'); break; case 'nextNumberOfDays': if (!val) return; - convertDayJsObjToStr = false; val = now.add(val, 'day'); break; } - if (filter.comparison_sub_op && convertDayJsObjToStr) { + if (dayjs.isDayjs(val)) { // turn `val` in dayjs object format to string val = val.format(dateFormat).toString(); // keep YYYY-MM-DD only for date