sql tree refactor

This commit is contained in:
Jan Prochazka
2020-03-05 12:23:07 +01:00
parent bf607fcb06
commit 95ae39e0de
13 changed files with 291 additions and 123 deletions

View File

@@ -0,0 +1,29 @@
import { SqlDumper } from "@dbgate/types";
import { Command, Select } from "./types";
export function dumpSqlSelect(dmp: SqlDumper, select: Select) {
dmp.put("^select ");
if (select.topRecords) {
dmp.put("^top %s ", select.topRecords);
}
if (select.distinct) {
dmp.put("^distinct ");
}
if (select.selectAll) {
dmp.put("* ");
} else {
// TODO
}
dmp.put("^from %f ", select.from);
if (select.range) {
dmp.put("^limit %s ^offset %s ", select.range.limit, select.range.offset);
}
}
export function dumpSqlCommand(dmp: SqlDumper, command: Command) {
switch (command.commandType) {
case "select":
dumpSqlSelect(dmp, command as Select);
break;
}
}