From 5b8d70747f13081cf4c2e4b49de3eab47fa07dd8 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 4 Sep 2022 08:47:58 +0200 Subject: [PATCH] fixed datetime null condition #356 --- packages/filterparser/src/datetimeParser.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/filterparser/src/datetimeParser.ts b/packages/filterparser/src/datetimeParser.ts index 93e22cf36..20dd79871 100644 --- a/packages/filterparser/src/datetimeParser.ts +++ b/packages/filterparser/src/datetimeParser.ts @@ -181,10 +181,23 @@ const binaryCondition = operator => value => ({ }, }); +const unaryCondition = conditionType => () => { + return { + conditionType, + expr: { + exprType: 'placeholder', + }, + }; +}; + const createParser = () => { const langDef = { comma: () => word(','), + not: () => word('NOT'), + notNull: r => r.not.then(r.null).map(unaryCondition('isNotNull')), + null: () => word('NULL').map(unaryCondition('isNull')), + yearNum: () => P.regexp(/\d\d\d\d/).map(yearCondition()), yearMonthNum: () => P.regexp(/\d\d\d\d-\d\d?/).map(yearMonthCondition()), yearMonthDayNum: () => P.regexp(/\d\d\d\d-\d\d?-\d\d?/).map(yearMonthDayCondition()), @@ -264,6 +277,8 @@ const createParser = () => { r.lastYear, r.thisYear, r.nextYear, + r.null, + r.notNull, r.le, r.lt, r.ge,