mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 11:03:57 +00:00
fixed filtering in json columns for postgres #889
This commit is contained in:
@@ -225,7 +225,7 @@ export abstract class GridDisplay {
|
|||||||
conditions.push(
|
conditions.push(
|
||||||
_.cloneDeepWith(condition, (expr: Expression) => {
|
_.cloneDeepWith(condition, (expr: Expression) => {
|
||||||
if (expr.exprType == 'placeholder') {
|
if (expr.exprType == 'placeholder') {
|
||||||
return this.createColumnExpression(column, { alias: column.sourceAlias });
|
return this.createColumnExpression(column, { alias: column.sourceAlias }, undefined, 'filter');
|
||||||
}
|
}
|
||||||
// return {
|
// return {
|
||||||
// exprType: 'column',
|
// exprType: 'column',
|
||||||
@@ -253,7 +253,7 @@ export abstract class GridDisplay {
|
|||||||
orCondition.conditions.push(
|
orCondition.conditions.push(
|
||||||
_.cloneDeepWith(condition, (expr: Expression) => {
|
_.cloneDeepWith(condition, (expr: Expression) => {
|
||||||
if (expr.exprType == 'placeholder') {
|
if (expr.exprType == 'placeholder') {
|
||||||
return this.createColumnExpression(column, { alias: 'basetbl' });
|
return this.createColumnExpression(column, { alias: 'basetbl' }, undefined, 'filter');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -570,10 +570,10 @@ export abstract class GridDisplay {
|
|||||||
|
|
||||||
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo, options) {}
|
processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo, options) {}
|
||||||
|
|
||||||
createColumnExpression(col, source, alias?) {
|
createColumnExpression(col, source, alias?, purpose: 'view' | 'filter' = 'view') {
|
||||||
let expr = null;
|
let expr = null;
|
||||||
if (this.dialect.createColumnViewExpression) {
|
if (this.dialect.createColumnViewExpression) {
|
||||||
expr = this.dialect.createColumnViewExpression(col.columnName, col.dataType, source, alias);
|
expr = this.dialect.createColumnViewExpression(col.columnName, col.dataType, source, alias, purpose);
|
||||||
if (expr) {
|
if (expr) {
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
@@ -595,7 +595,7 @@ export abstract class GridDisplay {
|
|||||||
name: _.pick(name, ['schemaName', 'pureName']),
|
name: _.pick(name, ['schemaName', 'pureName']),
|
||||||
alias: 'basetbl',
|
alias: 'basetbl',
|
||||||
},
|
},
|
||||||
columns: columns.map(col => this.createColumnExpression(col, { alias: 'basetbl' })),
|
columns: columns.map(col => this.createColumnExpression(col, { alias: 'basetbl' }, undefined, 'view')),
|
||||||
orderBy: this.driver?.requiresDefaultSortCriteria
|
orderBy: this.driver?.requiresDefaultSortCriteria
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export class TableGridDisplay extends GridDisplay {
|
|||||||
? this.table.primaryKey.columns.map(x => x.columnName)
|
? this.table.primaryKey.columns.map(x => x.columnName)
|
||||||
: this.table.columns.map(x => x.columnName);
|
: this.table.columns.map(x => x.columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.isFormView) {
|
if (this.config.isFormView) {
|
||||||
this.addAllExpandedColumnsToSelected = true;
|
this.addAllExpandedColumnsToSelected = true;
|
||||||
this.hintBaseColumns = this.formColumns;
|
this.hintBaseColumns = this.formColumns;
|
||||||
@@ -287,7 +287,7 @@ export class TableGridDisplay extends GridDisplay {
|
|||||||
for (const column of columns) {
|
for (const column of columns) {
|
||||||
if (this.addAllExpandedColumnsToSelected || this.config.addedColumns.includes(column.uniqueName)) {
|
if (this.addAllExpandedColumnsToSelected || this.config.addedColumns.includes(column.uniqueName)) {
|
||||||
select.columns.push(
|
select.columns.push(
|
||||||
this.createColumnExpression(column, { name: column, alias: parentAlias }, column.uniqueName)
|
this.createColumnExpression(column, { name: column, alias: parentAlias }, column.uniqueName, 'view')
|
||||||
);
|
);
|
||||||
displayedColumnInfo[column.uniqueName] = {
|
displayedColumnInfo[column.uniqueName] = {
|
||||||
...column,
|
...column,
|
||||||
|
|||||||
8
packages/types/dialect.d.ts
vendored
8
packages/types/dialect.d.ts
vendored
@@ -50,7 +50,13 @@ export interface SqlDialect {
|
|||||||
predefinedDataTypes: string[];
|
predefinedDataTypes: string[];
|
||||||
|
|
||||||
// create sql-tree expression
|
// create sql-tree expression
|
||||||
createColumnViewExpression(columnName: string, dataType: string, source: { alias: string }, alias?: string): any;
|
createColumnViewExpression(
|
||||||
|
columnName: string,
|
||||||
|
dataType: string,
|
||||||
|
source: { alias: string },
|
||||||
|
alias?: string,
|
||||||
|
purpose: 'view' | 'filter' = 'view'
|
||||||
|
): any;
|
||||||
|
|
||||||
getTableFormOptions(intent: 'newTableForm' | 'editTableForm' | 'sqlCreateTable' | 'sqlAlterTable'): {
|
getTableFormOptions(intent: 'newTableForm' | 'editTableForm' | 'sqlCreateTable' | 'sqlAlterTable'): {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const dialect = {
|
|||||||
'xml',
|
'xml',
|
||||||
],
|
],
|
||||||
|
|
||||||
createColumnViewExpression(columnName, dataType, source, alias) {
|
createColumnViewExpression(columnName, dataType, source, alias, purpose) {
|
||||||
if (dataType && spatialTypes.includes(dataType.toUpperCase())) {
|
if (dataType && spatialTypes.includes(dataType.toUpperCase())) {
|
||||||
return {
|
return {
|
||||||
exprType: 'call',
|
exprType: 'call',
|
||||||
@@ -100,7 +100,7 @@ const dialect = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataType?.toLowerCase() == 'uuid') {
|
if (dataType?.toLowerCase() == 'uuid' || (purpose == 'filter' && dataType?.toLowerCase()?.startsWith('json'))) {
|
||||||
return {
|
return {
|
||||||
exprType: 'unaryRaw',
|
exprType: 'unaryRaw',
|
||||||
expr: {
|
expr: {
|
||||||
|
|||||||
Reference in New Issue
Block a user