mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 00:16:00 +00:00
query result shown
This commit is contained in:
@@ -40,11 +40,12 @@ export function findExistingChangeSetItem(
|
||||
changeSet: ChangeSet,
|
||||
definition: ChangeSetRowDefinition
|
||||
): [keyof ChangeSet, ChangeSetItem] {
|
||||
if (!changeSet) return ['updates', null];
|
||||
if (definition.insertedRowIndex != null) {
|
||||
return [
|
||||
'inserts',
|
||||
changeSet.inserts.find(
|
||||
x =>
|
||||
(x) =>
|
||||
x.pureName == definition.pureName &&
|
||||
x.schemaName == definition.schemaName &&
|
||||
x.insertedRowIndex == definition.insertedRowIndex
|
||||
@@ -52,7 +53,7 @@ export function findExistingChangeSetItem(
|
||||
];
|
||||
} else {
|
||||
const inUpdates = changeSet.updates.find(
|
||||
x =>
|
||||
(x) =>
|
||||
x.pureName == definition.pureName &&
|
||||
x.schemaName == definition.schemaName &&
|
||||
_.isEqual(x.condition, definition.condition)
|
||||
@@ -60,7 +61,7 @@ export function findExistingChangeSetItem(
|
||||
if (inUpdates) return ['updates', inUpdates];
|
||||
|
||||
const inDeletes = changeSet.deletes.find(
|
||||
x =>
|
||||
(x) =>
|
||||
x.pureName == definition.pureName &&
|
||||
x.schemaName == definition.schemaName &&
|
||||
_.isEqual(x.condition, definition.condition)
|
||||
@@ -84,7 +85,7 @@ export function setChangeSetValue(
|
||||
if (existingItem) {
|
||||
return {
|
||||
...changeSet,
|
||||
[fieldName]: changeSet[fieldName].map(item =>
|
||||
[fieldName]: changeSet[fieldName].map((item) =>
|
||||
item == existingItem
|
||||
? {
|
||||
...item,
|
||||
@@ -164,7 +165,7 @@ export function batchUpdateChangeSet(
|
||||
}
|
||||
|
||||
function extractFields(item: ChangeSetItem): UpdateField[] {
|
||||
return _.keys(item.fields).map(targetColumn => ({
|
||||
return _.keys(item.fields).map((targetColumn) => ({
|
||||
targetColumn,
|
||||
exprType: 'value',
|
||||
value: item.fields[targetColumn],
|
||||
@@ -185,7 +186,7 @@ function insertToSql(item: ChangeSetItem): Insert {
|
||||
function extractCondition(item: ChangeSetItem): Condition {
|
||||
return {
|
||||
conditionType: 'and',
|
||||
conditions: _.keys(item.condition).map(columnName => ({
|
||||
conditions: _.keys(item.condition).map((columnName) => ({
|
||||
conditionType: 'binary',
|
||||
operator: '=',
|
||||
left: {
|
||||
@@ -248,7 +249,7 @@ export function revertChangeSetRowChanges(changeSet: ChangeSet, definition: Chan
|
||||
if (item)
|
||||
return {
|
||||
...changeSet,
|
||||
[field]: changeSet[field].filter(x => x != item),
|
||||
[field]: changeSet[field].filter((x) => x != item),
|
||||
};
|
||||
return changeSet;
|
||||
}
|
||||
@@ -280,8 +281,8 @@ export function deleteChangeSetRows(changeSet: ChangeSet, definition: ChangeSetR
|
||||
export function getChangeSetInsertedRows(changeSet: ChangeSet, name?: NamedObjectInfo) {
|
||||
if (!name) return [];
|
||||
if (!changeSet) return [];
|
||||
const rows = changeSet.inserts.filter(x => x.pureName == name.pureName && x.schemaName == name.schemaName);
|
||||
const maxIndex = _.maxBy(rows, x => x.insertedRowIndex)?.insertedRowIndex;
|
||||
const rows = changeSet.inserts.filter((x) => x.pureName == name.pureName && x.schemaName == name.schemaName);
|
||||
const maxIndex = _.maxBy(rows, (x) => x.insertedRowIndex)?.insertedRowIndex;
|
||||
if (maxIndex == null) return [];
|
||||
const res = Array(maxIndex + 1).fill({});
|
||||
for (const row of rows) {
|
||||
|
||||
@@ -55,6 +55,9 @@ export abstract class GridDisplay {
|
||||
columns: DisplayColumn[];
|
||||
baseTable?: TableInfo;
|
||||
changeSetKeyFields: string[] = null;
|
||||
sortable = false;
|
||||
filterable = false;
|
||||
editable = false;
|
||||
|
||||
setColumnVisibility(uniquePath: string[], isVisible: boolean) {
|
||||
const uniqueName = uniquePath.join('.');
|
||||
|
||||
@@ -16,11 +16,14 @@ export class TableGridDisplay extends GridDisplay {
|
||||
) {
|
||||
super(config, setConfig, cache, setCache, getTableInfo, driver);
|
||||
this.columns = this.getDisplayColumns(table, []);
|
||||
this.filterable = true;
|
||||
this.sortable = true;
|
||||
this.editable = true;
|
||||
this.baseTable = table;
|
||||
if (table && table.columns) {
|
||||
this.changeSetKeyFields = table.primaryKey
|
||||
? table.primaryKey.columns.map(x => x.columnName)
|
||||
: table.columns.map(x => x.columnName);
|
||||
? table.primaryKey.columns.map((x) => x.columnName)
|
||||
: table.columns.map((x) => x.columnName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +33,7 @@ export class TableGridDisplay extends GridDisplay {
|
||||
const select: Select = {
|
||||
commandType: 'select',
|
||||
from: { name: this.table, alias: 'basetbl' },
|
||||
columns: this.table.columns.map(col => ({
|
||||
columns: this.table.columns.map((col) => ({
|
||||
exprType: 'column',
|
||||
alias: col.columnName,
|
||||
source: { alias: 'basetbl' },
|
||||
@@ -45,7 +48,7 @@ export class TableGridDisplay extends GridDisplay {
|
||||
],
|
||||
};
|
||||
const displayedColumnInfo = _.keyBy(
|
||||
this.columns.map(col => ({ ...col, sourceAlias: 'basetbl' })),
|
||||
this.columns.map((col) => ({ ...col, sourceAlias: 'basetbl' })),
|
||||
'uniqueName'
|
||||
);
|
||||
const action = combineReferenceActions(
|
||||
|
||||
Reference in New Issue
Block a user