dbgate-datalib 4.6.3 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ChangeSet.js CHANGED
@@ -251,6 +251,16 @@ function revertChangeSetRowChanges(changeSet, definition) {
251
251
  return changeSet;
252
252
  }
253
253
  exports.revertChangeSetRowChanges = revertChangeSetRowChanges;
254
+ function consolidateInsertIndexes(changeSet, name) {
255
+ const indexes = changeSet.inserts
256
+ .filter(x => x.pureName == name.pureName && x.schemaName == name.schemaName)
257
+ .map(x => x.insertedRowIndex);
258
+ indexes.sort((a, b) => a - b);
259
+ if (indexes[indexes.length - 1] != indexes.length - 1) {
260
+ return Object.assign(Object.assign({}, changeSet), { inserts: changeSet.inserts.map(x => (Object.assign(Object.assign({}, x), { insertedRowIndex: indexes.indexOf(x.insertedRowIndex) }))) });
261
+ }
262
+ return changeSet;
263
+ }
254
264
  function deleteChangeSetRows(changeSet, definition) {
255
265
  let [fieldName, existingItem] = findExistingChangeSetItem(changeSet, definition);
256
266
  if (fieldName == 'updates') {
@@ -258,7 +268,7 @@ function deleteChangeSetRows(changeSet, definition) {
258
268
  [fieldName, existingItem] = findExistingChangeSetItem(changeSet, definition);
259
269
  }
260
270
  if (fieldName == 'inserts') {
261
- return revertChangeSetRowChanges(changeSet, definition);
271
+ return consolidateInsertIndexes(revertChangeSetRowChanges(changeSet, definition), definition);
262
272
  }
263
273
  else {
264
274
  if (existingItem && fieldName == 'deletes')
@@ -25,6 +25,9 @@ export declare class FreeTableGridDisplay extends GridDisplay {
25
25
  isSparse?: boolean;
26
26
  defaultValue?: string;
27
27
  defaultConstraint?: string;
28
+ columnComment?: string;
29
+ isUnsigned?: boolean;
30
+ isZerofill?: boolean;
28
31
  }[];
29
32
  getDisplayColumn(col: ColumnInfo): {
30
33
  pureName: string;
@@ -45,5 +48,8 @@ export declare class FreeTableGridDisplay extends GridDisplay {
45
48
  isSparse?: boolean;
46
49
  defaultValue?: string;
47
50
  defaultConstraint?: string;
51
+ columnComment?: string;
52
+ isUnsigned?: boolean;
53
+ isZerofill?: boolean;
48
54
  };
49
55
  }
@@ -54,6 +54,7 @@ export declare abstract class GridDisplay {
54
54
  isLoadedCorrectly: boolean;
55
55
  supportsReload: boolean;
56
56
  isDynamicStructure: boolean;
57
+ filterTypeOverride: any;
57
58
  setColumnVisibility(uniquePath: string[], isVisible: boolean): void;
58
59
  addDynamicColumn(name: string): void;
59
60
  focusColumns(uniqueNames: string[]): void;
@@ -27,6 +27,7 @@ class GridDisplay {
27
27
  this.isLoadedCorrectly = true;
28
28
  this.supportsReload = false;
29
29
  this.isDynamicStructure = false;
30
+ this.filterTypeOverride = null;
30
31
  this.dialect = ((driver === null || driver === void 0 ? void 0 : driver.dialectByVersion) && (driver === null || driver === void 0 ? void 0 : driver.dialectByVersion(serverVersion))) || (driver === null || driver === void 0 ? void 0 : driver.dialect);
31
32
  }
32
33
  get baseTableOrSimilar() {
@@ -462,22 +463,23 @@ class GridDisplay {
462
463
  return sql;
463
464
  }
464
465
  compileFilters() {
466
+ var _a;
465
467
  const filters = this.config && this.config.filters;
466
468
  if (!filters)
467
469
  return null;
468
470
  const conditions = [];
469
471
  for (const name in filters) {
470
- const column = this.columns.find(x => (x.columnName = name));
471
- if (!column)
472
+ const column = this.isDynamicStructure ? null : this.columns.find(x => x.columnName == name);
473
+ if (!this.isDynamicStructure && !column)
472
474
  continue;
473
- const filterType = (0, dbgate_filterparser_1.getFilterType)(column.dataType);
475
+ const filterType = this.isDynamicStructure ? (_a = this.filterTypeOverride) !== null && _a !== void 0 ? _a : 'mongo' : (0, dbgate_filterparser_1.getFilterType)(column.dataType);
474
476
  try {
475
477
  const condition = (0, dbgate_filterparser_1.parseFilter)(filters[name], filterType);
476
478
  const replaced = lodash_1.default.cloneDeepWith(condition, (expr) => {
477
479
  if (expr.exprType == 'placeholder')
478
480
  return {
479
481
  exprType: 'column',
480
- columnName: column.columnName,
482
+ columnName: this.isDynamicStructure ? name : column.columnName,
481
483
  };
482
484
  });
483
485
  conditions.push(replaced);
@@ -1,5 +1,5 @@
1
1
  import { GridDisplay, ChangeCacheFunc, ChangeConfigFunc } from './GridDisplay';
2
2
  import { GridConfig, GridCache } from './GridConfig';
3
3
  export declare class JslGridDisplay extends GridDisplay {
4
- constructor(jslid: any, structure: any, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, rows: any);
4
+ constructor(jslid: any, structure: any, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, rows: any, isDynamicStructure: boolean, supportsReload: boolean);
5
5
  }
@@ -8,10 +8,14 @@ const lodash_1 = __importDefault(require("lodash"));
8
8
  const GridDisplay_1 = require("./GridDisplay");
9
9
  const CollectionGridDisplay_1 = require("./CollectionGridDisplay");
10
10
  class JslGridDisplay extends GridDisplay_1.GridDisplay {
11
- constructor(jslid, structure, config, setConfig, cache, setCache, rows) {
11
+ constructor(jslid, structure, config, setConfig, cache, setCache, rows, isDynamicStructure, supportsReload) {
12
12
  var _a;
13
13
  super(config, setConfig, cache, setCache, null);
14
14
  this.filterable = true;
15
+ this.supportsReload = supportsReload;
16
+ this.isDynamicStructure = isDynamicStructure;
17
+ if (isDynamicStructure)
18
+ this.filterTypeOverride = 'string';
15
19
  if (structure === null || structure === void 0 ? void 0 : structure.columns) {
16
20
  this.columns = lodash_1.default.uniqBy((_a = structure.columns
17
21
  .map(col => ({
@@ -46,6 +46,9 @@ export declare class TableGridDisplay extends GridDisplay {
46
46
  isSparse?: boolean;
47
47
  defaultValue?: string;
48
48
  defaultConstraint?: string;
49
+ columnComment?: string;
50
+ isUnsigned?: boolean;
51
+ isZerofill?: boolean;
49
52
  }[];
50
53
  addJoinsFromExpandedColumns(select: Select, columns: DisplayColumn[], parentAlias: string, columnSources: any): void;
51
54
  addReferenceToSelect(select: Select, parentAlias: string, column: DisplayColumn): void;
@@ -79,6 +82,9 @@ export declare class TableGridDisplay extends GridDisplay {
79
82
  isSparse?: boolean;
80
83
  defaultValue?: string;
81
84
  defaultConstraint?: string;
85
+ columnComment?: string;
86
+ isUnsigned?: boolean;
87
+ isZerofill?: boolean;
82
88
  };
83
89
  addAddedColumnsToSelect(select: Select, columns: DisplayColumn[], parentAlias: string, displayedColumnInfo: DisplayedColumnInfo): void;
84
90
  get hasReferences(): boolean;
@@ -24,6 +24,9 @@ export declare class ViewGridDisplay extends GridDisplay {
24
24
  isSparse?: boolean;
25
25
  defaultValue?: string;
26
26
  defaultConstraint?: string;
27
+ columnComment?: string;
28
+ isUnsigned?: boolean;
29
+ isZerofill?: boolean;
27
30
  }[];
28
31
  getDisplayColumn(view: ViewInfo, col: ColumnInfo): {
29
32
  pureName: string;
@@ -44,6 +47,9 @@ export declare class ViewGridDisplay extends GridDisplay {
44
47
  isSparse?: boolean;
45
48
  defaultValue?: string;
46
49
  defaultConstraint?: string;
50
+ columnComment?: string;
51
+ isUnsigned?: boolean;
52
+ isZerofill?: boolean;
47
53
  };
48
54
  createSelect(options?: {}): import("dbgate-sqltree").Select;
49
55
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.6.3",
2
+ "version": "4.7.2",
3
3
  "name": "dbgate-datalib",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -11,11 +11,11 @@
11
11
  "lib"
12
12
  ],
13
13
  "dependencies": {
14
- "dbgate-sqltree": "^4.6.3",
15
- "dbgate-filterparser": "^4.6.3"
14
+ "dbgate-sqltree": "^4.7.2",
15
+ "dbgate-filterparser": "^4.7.2"
16
16
  },
17
17
  "devDependencies": {
18
- "dbgate-types": "^4.6.3",
18
+ "dbgate-types": "^4.7.2",
19
19
  "@types/node": "^13.7.0",
20
20
  "typescript": "^4.4.3"
21
21
  }