custom SQL condition #369

This commit is contained in:
Jan Prochazka
2022-09-17 21:42:20 +02:00
parent a89c6810aa
commit 973f64f4d7
4 changed files with 51 additions and 3 deletions

View File

@@ -72,5 +72,15 @@ export function dumpSqlCondition(dmp: SqlDumper, condition: Condition) {
dumpSqlExpression(dmp, condition.expr);
dmp.put(' ^in (%,v)', condition.values);
break;
case 'rawTemplate':
let was = false;
for (const item of condition.templateSql.split('$$')) {
if (was) {
dumpSqlExpression(dmp, condition.expr);
}
dmp.putRaw(item);
was = true;
}
break;
}
}

View File

@@ -105,6 +105,12 @@ export interface InCondition {
values: any[];
}
export interface RawTemplateCondition {
conditionType: 'rawTemplate';
templateSql: string;
expr: Expression;
}
export type Condition =
| BinaryCondition
| NotCondition
@@ -114,7 +120,8 @@ export type Condition =
| ExistsCondition
| NotExistsCondition
| BetweenCondition
| InCondition;
| InCondition
| RawTemplateCondition;
export interface Source {
name?: NamedObjectInfo;