expression parser

This commit is contained in:
Jan Prochazka
2020-03-12 12:46:07 +01:00
parent e2c5c8163c
commit 064121376f
15 changed files with 1306 additions and 100 deletions

View File

@@ -1,3 +1,4 @@
import _ from 'lodash';
import { SqlDumper } from '@dbgate/types';
import { Expression, ColumnRefExpression } from './types';
import { dumpSqlSourceRef } from './dumpSqlSource';
@@ -14,5 +15,13 @@ export function dumpSqlExpression(dmp: SqlDumper, expr: Expression) {
dmp.put('%i', expr.columnName);
}
break;
case 'placeholder':
dmp.putRaw('{PLACEHOLDER}');
break;
case 'value':
dmp.put('%v', expr.value);
break;
}
}

View File

@@ -70,7 +70,11 @@ export interface ValueExpression {
value: any;
}
export type Expression = ColumnRefExpression | ValueExpression;
export interface PlaceholderExpression {
exprType: 'placeholder';
}
export type Expression = ColumnRefExpression | ValueExpression | PlaceholderExpression;
export type OrderByExpression = Expression & { direction: 'ASC' | 'DESC' };
export type ResultField = Expression & { alias?: string };