@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.
- package/__tests__/connectors/mssql/expect-out-files/schema.json +140 -106
- package/__tests__/connectors/mysql/expect-out-files/schema.json +40 -0
- package/__tests__/connectors/postgres/expect-out-files/schema.json +100 -0
- package/dist/connectors/bigqueryConnector.js +4 -2
- package/dist/connectors/mssqlConnector.js +70 -140
- package/dist/connectors/mysqlConnector.js +66 -7
- package/dist/connectors/postgresConnector.d.ts +1 -1
- package/dist/connectors/postgresConnector.js +97 -29
- package/dist/connectors/snowflakeConnector.js +8 -5
- package/dist/connectors/types.d.ts +10 -6
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +14 -3
- package/package.json +2 -2
- package/src/connectors/bigqueryConnector.ts +4 -2
- package/src/connectors/mssqlConnector.ts +74 -149
- package/src/connectors/mysqlConnector.ts +76 -11
- package/src/connectors/postgresConnector.ts +104 -29
- package/src/connectors/snowflakeConnector.ts +19 -15
- package/src/connectors/types.ts +16 -61
- package/src/utils/helpers.ts +30 -12
- package/__tests__/connectors/mssql/out-files/schema.json +0 -2074
- package/__tests__/connectors/mysql/out-files/schema.json +0 -1430
- package/__tests__/connectors/postgres/out-files/schema.json +0 -1719
package/src/utils/helpers.ts
CHANGED
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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
|
+
}
|