mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixes
This commit is contained in:
parent
64e770f51e
commit
12d60c7ed9
@ -9,7 +9,15 @@ import type {
|
||||
TableInfo,
|
||||
ViewInfo,
|
||||
} from 'dbgate-types';
|
||||
import { detectSqlFilterBehaviour, equalFullName, isCollectionInfo, isTableInfo, isViewInfo, stringFilterBehaviour } from 'dbgate-tools';
|
||||
import {
|
||||
detectSqlFilterBehaviour,
|
||||
equalFullName,
|
||||
isCollectionInfo,
|
||||
isTableInfo,
|
||||
isViewInfo,
|
||||
mongoFilterBehaviour,
|
||||
stringFilterBehaviour,
|
||||
} from 'dbgate-tools';
|
||||
import {
|
||||
ChangePerspectiveConfigFunc,
|
||||
createPerspectiveNodeConfig,
|
||||
@ -346,7 +354,7 @@ export abstract class PerspectiveTreeNode {
|
||||
const base = this.getBaseTableFromThis() as TableInfo | ViewInfo;
|
||||
if (!base) return null;
|
||||
try {
|
||||
const condition = parseFilter(this.nodeConfig?.multiColumnFilter, 'string');
|
||||
const condition = parseFilter(this.nodeConfig?.multiColumnFilter, stringFilterBehaviour);
|
||||
if (condition) {
|
||||
const orCondition: CompoudCondition = {
|
||||
conditionType: 'or',
|
||||
@ -380,7 +388,7 @@ export abstract class PerspectiveTreeNode {
|
||||
const pattern = this.dataProvider?.dataPatterns?.[this.designerId];
|
||||
if (!pattern) return null;
|
||||
|
||||
const condition = parseFilter(this.nodeConfig?.multiColumnFilter, 'mongo');
|
||||
const condition = parseFilter(this.nodeConfig?.multiColumnFilter, mongoFilterBehaviour);
|
||||
if (!condition) return null;
|
||||
const res = pattern.columns.map(col => {
|
||||
return _cloneDeepWith(condition, expr => {
|
||||
@ -951,7 +959,7 @@ export class PerspectivePatternColumnNode extends PerspectiveTreeNode {
|
||||
|
||||
get filterBehaviour(): FilterBehaviour {
|
||||
if (this.tableColumn) return detectSqlFilterBehaviour(this.tableColumn.dataType);
|
||||
return 'mongo';
|
||||
return mongoFilterBehaviour;
|
||||
}
|
||||
|
||||
get preloadedLevelData() {
|
||||
@ -1093,7 +1101,7 @@ export class PerspectivePatternColumnNode extends PerspectiveTreeNode {
|
||||
parseFilterCondition(source = null): {} {
|
||||
const filter = this.getFilter();
|
||||
if (!filter) return null;
|
||||
const condition = parseFilter(filter, 'mongo');
|
||||
const condition = parseFilter(filter, mongoFilterBehaviour);
|
||||
if (!condition) return null;
|
||||
return _cloneDeepWith(condition, expr => {
|
||||
if (expr.__placeholder__) {
|
||||
|
@ -227,7 +227,9 @@ function getParser(filterBehaviour: FilterBehaviour) {
|
||||
|
||||
export function parseFilter(value: string, filterBehaviour: FilterBehaviour): Condition {
|
||||
const parser = getParser(filterBehaviour);
|
||||
console.log('value', value);
|
||||
console.log('filterBehaviour', filterBehaviour);
|
||||
const ast = parser.list.tryParse(value);
|
||||
// console.log('AST', ast);
|
||||
console.log('AST', ast);
|
||||
return ast;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ export const logicalFilterBehaviour: FilterBehaviour = {
|
||||
};
|
||||
|
||||
export const datetimeFilterBehaviour: FilterBehaviour = {
|
||||
compilerType: 'sqlTree',
|
||||
compilerType: 'datetime',
|
||||
supportNullTesting: true,
|
||||
supportSqlCondition: true,
|
||||
supportDatetimeSymbols: true,
|
||||
@ -59,7 +59,7 @@ export const evalFilterBehaviour: FilterBehaviour = {
|
||||
allowStringToken: true,
|
||||
};
|
||||
|
||||
export const standardFilterBehaviours = {
|
||||
export const standardFilterBehaviours: { [id: string]: FilterBehaviour } = {
|
||||
numberFilterBehaviour,
|
||||
stringFilterBehaviour,
|
||||
logicalFilterBehaviour,
|
||||
|
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@ -73,7 +73,7 @@ export interface ServerSummary {
|
||||
}
|
||||
|
||||
export interface FilterBehaviourProvider {
|
||||
getFilterBehaviour(dataType: string, standardFilterBehaviours: { string: FilterBehaviour }): FilterBehaviour;
|
||||
getFilterBehaviour(dataType: string, standardFilterBehaviours: { [id: string]: FilterBehaviour }): FilterBehaviour;
|
||||
}
|
||||
|
||||
export interface EngineDriver extends FilterBehaviourProvider {
|
||||
|
@ -26,7 +26,7 @@
|
||||
for (const uniqueName in filters || {}) {
|
||||
if (!filters[uniqueName]) continue;
|
||||
try {
|
||||
const ast = parseFilter(filters[uniqueName], 'mongo');
|
||||
const ast = parseFilter(filters[uniqueName], mongoFilterBehaviour);
|
||||
// console.log('AST', ast);
|
||||
const cond = _.cloneDeepWith(ast, expr => {
|
||||
if (expr.__placeholder__) {
|
||||
@ -123,6 +123,7 @@
|
||||
import ChangeSetGrider from './ChangeSetGrider';
|
||||
|
||||
import LoadingDataGridCore from './LoadingDataGridCore.svelte';
|
||||
import { mongoFilterBehaviour } from 'dbgate-tools';
|
||||
|
||||
export let conid;
|
||||
export let display;
|
||||
|
Loading…
Reference in New Issue
Block a user