From 85a43c7a5bd3290a9431971ee9514990c599c89a Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Wed, 10 Jul 2024 14:36:25 +0200 Subject: [PATCH] sqltree: notIn support --- packages/sqltree/src/dumpSqlCondition.ts | 4 ++++ packages/sqltree/src/types.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/packages/sqltree/src/dumpSqlCondition.ts b/packages/sqltree/src/dumpSqlCondition.ts index a95fa86f..96798e4b 100644 --- a/packages/sqltree/src/dumpSqlCondition.ts +++ b/packages/sqltree/src/dumpSqlCondition.ts @@ -72,6 +72,10 @@ export function dumpSqlCondition(dmp: SqlDumper, condition: Condition) { dumpSqlExpression(dmp, condition.expr); dmp.put(' ^in (%,v)', condition.values); break; + case 'notIn': + dumpSqlExpression(dmp, condition.expr); + dmp.put(' ^not ^in (%,v)', condition.values); + break; case 'rawTemplate': let was = false; for (const item of condition.templateSql.split('$$')) { diff --git a/packages/sqltree/src/types.ts b/packages/sqltree/src/types.ts index cda154a7..ed72f33c 100644 --- a/packages/sqltree/src/types.ts +++ b/packages/sqltree/src/types.ts @@ -106,6 +106,12 @@ export interface InCondition { values: any[]; } +export interface NotInCondition { + conditionType: 'notIn'; + expr: Expression; + values: any[]; +} + export interface RawTemplateCondition { conditionType: 'rawTemplate'; templateSql: string; @@ -127,6 +133,7 @@ export type Condition = | NotExistsCondition | BetweenCondition | InCondition + | NotInCondition | RawTemplateCondition | AnyColumnPassEvalOnlyCondition;