sql tree - before refactor

This commit is contained in:
Jan Prochazka
2020-03-05 11:42:16 +01:00
parent 0507e84457
commit bf607fcb06
12 changed files with 136 additions and 18 deletions

View File

@@ -1,19 +1,30 @@
import GridDisplay from "./GridDisplay";
import { Select } from "@dbgate/sqltree";
import { TableInfo, EngineDriver } from "@dbgate/types";
import GridConfig from "./GridConfig";
export default class TableGridDisplay extends GridDisplay {
constructor(public table: TableInfo, public driver: EngineDriver) {
super();
constructor(
public table: TableInfo,
public driver: EngineDriver,
config: GridConfig,
setConfig: (configh: GridConfig) => void
) {
super(config, setConfig);
}
createSelect() {
const select = new Select();
select.from = this.table;
select.selectAll = true;
return select;
}
getPageQuery(offset: number, count: number) {
const select = new Select();
const select = this.createSelect();
if (this.driver.dialect.limitSelect) select.topRecords = count;
if (this.driver.dialect.rangeSelect)
select.range = { offset: offset, limit: count };
select.from = this.table;
select.selectAll = true;
const sql = select.toSql(this.driver);
return sql;
}