mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 13:46:00 +00:00
filter parser
This commit is contained in:
@@ -5,11 +5,34 @@ import { dumpSqlExpression } from './dumpSqlExpression';
|
||||
export function dumpSqlCondition(dmp: SqlDumper, condition: Condition) {
|
||||
switch (condition.conditionType) {
|
||||
case 'binary':
|
||||
dmp.put('(');
|
||||
dumpSqlExpression(dmp, condition.left);
|
||||
dmp.put(' %s ', condition.operator);
|
||||
dumpSqlExpression(dmp, condition.right);
|
||||
dmp.put(')');
|
||||
break;
|
||||
case 'isNull':
|
||||
dumpSqlExpression(dmp, condition.expr);
|
||||
dmp.put(' ^is ^null');
|
||||
break;
|
||||
case 'isNotNull':
|
||||
dumpSqlExpression(dmp, condition.expr);
|
||||
dmp.put(' ^is ^not ^null');
|
||||
break;
|
||||
case 'isEmpty':
|
||||
dmp.put('^trim(');
|
||||
dumpSqlExpression(dmp, condition.expr);
|
||||
dmp.put(") = ''");
|
||||
break;
|
||||
case 'isNotEmpty':
|
||||
dmp.put('^trim(');
|
||||
dumpSqlExpression(dmp, condition.expr);
|
||||
dmp.put(") <> ''");
|
||||
break;
|
||||
case 'and':
|
||||
case 'or':
|
||||
dmp.putCollection(` ^${condition.conditionType} `, condition.conditions, cond => {
|
||||
dmp.putRaw('(');
|
||||
dumpSqlCondition(dmp, cond);
|
||||
dmp.putRaw(')');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user