@dbml/connector 5.0.0-alpha.0 → 5.1.0

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.
@@ -1,15 +1,16 @@
1
1
  import {
2
+ CheckConstraintDictionary,
2
3
  FieldsDictionary,
3
4
  IndexesDictionary,
4
5
  Table,
5
6
  TableConstraintsDictionary,
6
7
  } from '../connectors/types';
7
8
 
8
- export function getIntersection<T>(firstList: T[], secondList: T[]): T[] {
9
+ export function getIntersection<T> (firstList: T[], secondList: T[]): T[] {
9
10
  return firstList.filter((item) => secondList.includes(item));
10
11
  }
11
12
 
12
- export function getTableSchemaKey(schemaName: string, tableName: string) {
13
+ export function getTableSchemaKey (schemaName: string, tableName: string) {
13
14
  if (!tableName || !tableName.trim()) {
14
15
  throw new Error('Table name must be a non-empty string');
15
16
  }
@@ -17,15 +18,15 @@ export function getTableSchemaKey(schemaName: string, tableName: string) {
17
18
  return schemaName ? `${schemaName}.${tableName}` : `${tableName}`;
18
19
  }
19
20
 
20
- export function mergeTables(firstTableList: Table[], secondTable: Table[]): Table[] {
21
+ export function mergeTables (firstTableList: Table[], secondTable: Table[]): Table[] {
21
22
  return firstTableList.concat(secondTable);
22
23
  }
23
24
 
24
- export function mergeFieldDictionary(
25
+ export function mergeFieldDictionary (
25
26
  firstDict: FieldsDictionary,
26
- secondDict: FieldsDictionary
27
+ secondDict: FieldsDictionary,
27
28
  ): FieldsDictionary {
28
- const result: FieldsDictionary = Object.assign({}, firstDict);
29
+ const result: FieldsDictionary = { ...firstDict };
29
30
 
30
31
  Object.keys(secondDict).forEach((key) => {
31
32
  if (!result[key]) {
@@ -38,11 +39,11 @@ export function mergeFieldDictionary(
38
39
  return result;
39
40
  }
40
41
 
41
- export function mergeIndexDictionary(
42
+ export function mergeIndexDictionary (
42
43
  firstDict: IndexesDictionary,
43
- secondDict: IndexesDictionary
44
+ secondDict: IndexesDictionary,
44
45
  ): IndexesDictionary {
45
- const result: IndexesDictionary = Object.assign({}, firstDict);
46
+ const result: IndexesDictionary = { ...firstDict };
46
47
 
47
48
  Object.keys(secondDict).forEach((key) => {
48
49
  if (!result[key]) {
@@ -55,11 +56,11 @@ export function mergeIndexDictionary(
55
56
  return result;
56
57
  }
57
58
 
58
- export function mergeTableConstraintDictionary(
59
+ export function mergeTableConstraintDictionary (
59
60
  firstDict: TableConstraintsDictionary,
60
- secondDict: TableConstraintsDictionary
61
+ secondDict: TableConstraintsDictionary,
61
62
  ): TableConstraintsDictionary {
62
- const result: TableConstraintsDictionary = Object.assign({}, firstDict);
63
+ const result: TableConstraintsDictionary = { ...firstDict };
63
64
 
64
65
  Object.keys(secondDict).forEach((key) => {
65
66
  if (!result[key]) {
@@ -71,3 +72,20 @@ export function mergeTableConstraintDictionary(
71
72
 
72
73
  return result;
73
74
  }
75
+
76
+ export function mergeCheckConstraintDictionary (
77
+ firstDict: CheckConstraintDictionary,
78
+ secondDict: CheckConstraintDictionary,
79
+ ): CheckConstraintDictionary {
80
+ const result: CheckConstraintDictionary = { ...firstDict };
81
+
82
+ Object.keys(secondDict).forEach((key) => {
83
+ if (!result[key]) {
84
+ result[key] = [];
85
+ }
86
+
87
+ result[key] = result[key].concat(secondDict[key]);
88
+ });
89
+
90
+ return result;
91
+ }