From 9f16ae77602277b1ac7d3e0ec2af854280121ad4 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 3 Feb 2023 19:57:02 +0800 Subject: [PATCH] feat(nocodb): prevent empty value for date & datetime values for filtering --- .../src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts | 9 +++++++++ 1 file changed, 9 insertions(+) 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 8a8c65ded4..b47277da18 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 @@ -271,6 +271,15 @@ const parseConditionV2 = async ( return (qb: Knex.QueryBuilder) => { let [field, val] = [_field, _val]; + if ( + [UITypes.Date, UITypes.DateTime].includes(column.uidt) && + !val && + ['is', 'isnot'].includes(filter.comparison_op) + ) { + // for date & datetime, + // val cannot be empty for non-is & non-isnot filters + return; + } switch (filter.comparison_op) { case 'eq': if (qb?.client?.config?.client === 'mysql2') {