query history - prepare

This commit is contained in:
Jan Prochazka
2021-06-03 14:26:21 +02:00
parent bebdf3f43b
commit 2a47f60987
26 changed files with 131 additions and 51 deletions

View File

@@ -1,19 +1,7 @@
import _ from 'lodash';
import { GridConfig, GridCache, GridConfigColumns, createGridCache, GroupFunc } from './GridConfig';
import {
ForeignKeyInfo,
TableInfo,
ColumnInfo,
EngineDriver,
NamedObjectInfo,
DatabaseInfo,
SqlDialect,
} from 'dbgate-types';
import { parseFilter, getFilterType, getFilterValueExpression } from 'dbgate-filterparser';
import { filterName } from './filterName';
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
import { Expression, Select, treeToSql, dumpSqlSelect, Condition } from 'dbgate-sqltree';
import { isTypeLogical } from 'dbgate-tools';
import { TableInfo, EngineDriver, DatabaseInfo, SqlDialect } from 'dbgate-types';
import { getFilterValueExpression } from 'dbgate-filterparser';
import { ChangeCacheFunc, ChangeConfigFunc, DisplayColumn } from './GridDisplay';
export class FormViewDisplay {

View File

@@ -11,7 +11,7 @@ import {
SqlDialect,
} from 'dbgate-types';
import { parseFilter, getFilterType } from 'dbgate-filterparser';
import { filterName } from './filterName';
import { filterName } from 'dbgate-tools';
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
import { Expression, Select, treeToSql, dumpSqlSelect, Condition } from 'dbgate-sqltree';
import { isTypeLogical } from 'dbgate-tools';

View File

@@ -12,7 +12,6 @@ import {
Condition,
OrderByExpression,
} from 'dbgate-sqltree';
import { filterName } from './filterName';
import { TableGridDisplay } from './TableGridDisplay';
import stableStringify from 'json-stable-stringify';
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';

View File

@@ -1,9 +1,9 @@
import _ from 'lodash';
import { filterName } from 'dbgate-tools';
import { GridDisplay, ChangeCacheFunc, DisplayColumn, DisplayedColumnInfo, ChangeConfigFunc } from './GridDisplay';
import { TableInfo, EngineDriver, ViewInfo, ColumnInfo, NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
import { GridConfig, GridCache, createGridCache } from './GridConfig';
import { Expression, Select, treeToSql, dumpSqlSelect } from 'dbgate-sqltree';
import { filterName } from './filterName';
export class TableGridDisplay extends GridDisplay {
public table: TableInfo;

View File

@@ -1,44 +0,0 @@
import _ from 'lodash';
// original C# variant
// public bool Match(string value)
// {
// if (String.IsNullOrEmpty(Filter)) return false;
// if (String.IsNullOrEmpty(value)) return true;
// var camelVariants = new HashSet<string>();
// camelVariants.Add(new String(value.Where(Char.IsUpper).ToArray()));
// if (value.All(x => Char.IsUpper(x) || x == '_'))
// {
// var sb = new StringBuilder();
// for (int i = 0; i < value.Length; i++)
// {
// if (Char.IsUpper(value[i]) && (i == 0 || value[i - 1] == '_')) sb.Append(value[i]);
// }
// camelVariants.Add(sb.ToString());
// }
// else
// {
// string s = value, s0;
// do
// {
// s0 = s;
// s = Regex.Replace(s, "([A-Z])([A-Z])([A-Z])", "$1$3");
// } while (s0 != s);
// camelVariants.Add(new String(s.Where(Char.IsUpper).ToArray()));
// }
// bool camelMatch = camelVariants.Any(x => DoMatch(Filter, x));
// if (Filter.All(Char.IsUpper)) return camelMatch;
// return DoMatch(Filter, value) || camelMatch;
// }
export function filterName(filter: string, ...names: string[]) {
if (!filter) return true;
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
const tokens = filter.split(' ').map(x => x.trim());
return !!_.compact(names).find(name => !tokens.find(token => !name.toUpperCase().includes(token.toUpperCase())));
// return name.toUpperCase().includes(filter.toUpperCase());
}

View File

@@ -4,7 +4,6 @@ export * from './TableGridDisplay';
export * from './ViewGridDisplay';
export * from './JslGridDisplay';
export * from './ChangeSet';
export * from './filterName';
export * from './FreeTableGridDisplay';
export * from './FreeTableModel';
export * from './MacroDefinition';