incremental data loading, flattened some sqltree types

This commit is contained in:
Jan Prochazka
2020-03-05 15:04:06 +01:00
parent 6b3e4e7cbf
commit d4b359f5a0
9 changed files with 45 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
import GridDisplay from './GridDisplay';
import { Select, treeToSql, dumpSqlSelect, createColumnResultField } from '@dbgate/sqltree';
import { Select, treeToSql, dumpSqlSelect } from '@dbgate/sqltree';
import { TableInfo, EngineDriver } from '@dbgate/types';
import GridConfig from './GridConfig';
@@ -15,20 +15,26 @@ export default class TableGridDisplay extends GridDisplay {
}
createSelect() {
const orderColumnName = this.table.columns[0].columnName;
const select: Select = {
commandType: 'select',
from: {
source: { name: this.table },
},
columns: this.table.columns.map(col => createColumnResultField(col.columnName)),
from: { name: this.table },
columns: this.table.columns.map(col => ({ exprType: 'column', ...col })),
orderBy: [
{
exprType: 'column',
columnName: orderColumnName,
direction: 'ASC',
},
],
};
return select;
}
getPageQuery(offset: number, count: number) {
const select = this.createSelect();
if (this.driver.dialect.limitSelect) select.topRecords = count;
if (this.driver.dialect.rangeSelect) select.range = { offset: offset, limit: count };
else if (this.driver.dialect.limitSelect) select.topRecords = count;
const sql = treeToSql(this.driver, select, dumpSqlSelect);
return sql;
}