introduced sqltree typescript library

This commit is contained in:
Jan Prochazka
2020-03-05 07:35:23 +01:00
parent 17e2c18c49
commit bbc969fa71
12 changed files with 88 additions and 53 deletions

View File

@@ -0,0 +1,13 @@
import { EngineDriver, SqlDumper } from "@dbgate/types";
class Command {
toSql(driver: EngineDriver) {
const dumper = driver.createDumper();
this.dumpSql(dumper);
return dumper.s;
}
dumpSql(dumper: SqlDumper) {}
}
export default Command;

View File

@@ -0,0 +1,31 @@
import Command from "./Command";
import { NamedObjectInfo, RangeDefinition, SqlDumper } from "@dbgate/types";
class Select extends Command {
topRecords: number;
from: NamedObjectInfo;
range: RangeDefinition;
distinct = false;
selectAll = false;
dumpSql(dumper: SqlDumper) {
dumper.put("^select ");
if (this.topRecords) {
dumper.put("^top %s ", this.topRecords);
}
if (this.distinct) {
dumper.put("^distinct ");
}
if (this.selectAll) {
dumper.put("* ");
} else {
// TODO
}
dumper.put("^from %f ", this.from);
if (this.range) {
dumper.put("^limit %s ^offset %s ", this.range.limit, this.range.offset);
}
}
}
export default Select;

View File

@@ -0,0 +1,2 @@
export { default as Select } from "./Select";
export { default as Command } from "./Command";