mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 16:13:58 +00:00
custom grid display fix
This commit is contained in:
@@ -20,6 +20,8 @@ export interface CustomGridColumn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class CustomGridDisplay extends GridDisplay {
|
export class CustomGridDisplay extends GridDisplay {
|
||||||
|
customColumns: CustomGridColumn[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public tableName: NamedObjectInfo,
|
public tableName: NamedObjectInfo,
|
||||||
columns: CustomGridColumn[],
|
columns: CustomGridColumn[],
|
||||||
@@ -35,6 +37,8 @@ export class CustomGridDisplay extends GridDisplay {
|
|||||||
) {
|
) {
|
||||||
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
|
||||||
|
|
||||||
|
this.customColumns = columns;
|
||||||
|
|
||||||
this.columns = columns.map(col => ({
|
this.columns = columns.map(col => ({
|
||||||
columnName: col.columnName,
|
columnName: col.columnName,
|
||||||
headerText: col.columnLabel,
|
headerText: col.columnLabel,
|
||||||
@@ -63,12 +67,15 @@ export class CustomGridDisplay extends GridDisplay {
|
|||||||
createSelect(options = {}) {
|
createSelect(options = {}) {
|
||||||
const select = this.createSelectBase(
|
const select = this.createSelectBase(
|
||||||
this.tableName,
|
this.tableName,
|
||||||
|
[],
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.columns.map(col => ({
|
// this.columns.map(col => ({
|
||||||
columnName: col.columnName,
|
// columnName: col.columnName,
|
||||||
})),
|
// })),
|
||||||
options
|
options,
|
||||||
|
this.customColumns.find(x => x.isPrimaryKey)?.columnName
|
||||||
);
|
);
|
||||||
|
select.selectAll = true;
|
||||||
if (this.additionalcondition) {
|
if (this.additionalcondition) {
|
||||||
if (select.where) {
|
if (select.where) {
|
||||||
select.where = {
|
select.where = {
|
||||||
|
|||||||
@@ -554,9 +554,9 @@ export abstract class GridDisplay {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options) {
|
createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options, defaultOrderColumnName?: string) {
|
||||||
if (!columns) return null;
|
if (!columns) return null;
|
||||||
const orderColumnName = columns[0].columnName;
|
const orderColumnName = defaultOrderColumnName ?? columns[0]?.columnName;
|
||||||
const select: Select = {
|
const select: Select = {
|
||||||
commandType: 'select',
|
commandType: 'select',
|
||||||
from: {
|
from: {
|
||||||
@@ -732,6 +732,7 @@ export abstract class GridDisplay {
|
|||||||
alias: 'count',
|
alias: 'count',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
select.selectAll = false;
|
||||||
}
|
}
|
||||||
return select;
|
return select;
|
||||||
// const sql = treeToSql(this.driver, select, dumpSqlSelect);
|
// const sql = treeToSql(this.driver, select, dumpSqlSelect);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
|
|||||||
if (cmd.selectAll) {
|
if (cmd.selectAll) {
|
||||||
dmp.put('* ');
|
dmp.put('* ');
|
||||||
}
|
}
|
||||||
if (cmd.columns) {
|
if (cmd.columns && cmd.columns.length > 0) {
|
||||||
if (cmd.selectAll) dmp.put('&n,');
|
if (cmd.selectAll) dmp.put('&n,');
|
||||||
dmp.put('&>&n');
|
dmp.put('&>&n');
|
||||||
dmp.putCollection(',&n', cmd.columns, fld => {
|
dmp.putCollection(',&n', cmd.columns, fld => {
|
||||||
|
|||||||
Reference in New Issue
Block a user