@mikro-orm/knex 6.1.10-dev.1 → 6.1.10-dev.3
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/AbstractSqlDriver.js +32 -13
- package/package.json +2 -2
- package/query/QueryBuilder.js +5 -0
- package/query/QueryBuilderHelper.js +5 -3
- package/schema/DatabaseSchema.d.ts +16 -2
- package/schema/DatabaseSchema.js +20 -3
- package/schema/DatabaseTable.d.ts +5 -1
- package/schema/SchemaComparator.js +23 -1
- package/schema/SqlSchemaGenerator.js +17 -12
- package/typings.d.ts +9 -0
package/AbstractSqlDriver.js
CHANGED
|
@@ -187,6 +187,10 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
187
187
|
path += '[pivot]';
|
|
188
188
|
}
|
|
189
189
|
const relationAlias = qb.getAliasForJoinPath(path, { matchPopulateJoins: true });
|
|
190
|
+
/* istanbul ignore next */
|
|
191
|
+
if (!relationAlias) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
190
194
|
// pivot ref joins via joined strategy need to be handled separately here, as they dont join the target entity
|
|
191
195
|
if (pivotRefJoin) {
|
|
192
196
|
let item;
|
|
@@ -212,10 +216,10 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
212
216
|
}));
|
|
213
217
|
if (!hasPK) {
|
|
214
218
|
if ([core_1.ReferenceKind.MANY_TO_MANY, core_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
|
|
215
|
-
result[prop.name]
|
|
219
|
+
result[prop.name] = [];
|
|
216
220
|
}
|
|
217
221
|
if ([core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
|
|
218
|
-
result[prop.name]
|
|
222
|
+
result[prop.name] = null;
|
|
219
223
|
}
|
|
220
224
|
return;
|
|
221
225
|
}
|
|
@@ -709,12 +713,12 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
709
713
|
const alias = qb.getNextAlias(prop.targetMeta.tableName);
|
|
710
714
|
qb.leftJoin(`${targetAlias}.${hint.field}`, alias);
|
|
711
715
|
// eslint-disable-next-line dot-notation
|
|
712
|
-
Object.values(qb['_joins'])
|
|
716
|
+
for (const join of Object.values(qb['_joins'])) {
|
|
713
717
|
const [propName] = hint.field.split(':', 2);
|
|
714
718
|
if (join.alias === alias && join.prop.name === propName) {
|
|
715
719
|
fields.push(...qb.helper.mapJoinColumns(qb.type, join));
|
|
716
720
|
}
|
|
717
|
-
}
|
|
721
|
+
}
|
|
718
722
|
});
|
|
719
723
|
}
|
|
720
724
|
qb.select(fields)
|
|
@@ -724,19 +728,30 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
724
728
|
if (owners.length === 1 && (options.offset != null || options.limit != null)) {
|
|
725
729
|
qb.limit(options.limit, options.offset);
|
|
726
730
|
}
|
|
731
|
+
// console.log('pivot qb', qb, qb._fields);
|
|
727
732
|
const res = owners.length ? await this.rethrow(qb.execute('all', { mergeResults: false, mapResults: false })) : [];
|
|
728
|
-
|
|
733
|
+
// console.log(res);
|
|
734
|
+
// const items = res.map((row: Dictionary) => super.mapResult(row, prop.targetMeta));
|
|
735
|
+
const tmp = {};
|
|
736
|
+
// const items = res.map((row: Dictionary) => this.mapResult(row, prop.targetMeta!, populate, qb, tmp));
|
|
737
|
+
// const items = res.map((row: Dictionary) => this.mapResult(row, pivotMeta, populate, qb, tmp));
|
|
738
|
+
const items = res.map((row) => {
|
|
739
|
+
const root = super.mapResult(row, prop.targetMeta);
|
|
740
|
+
this.mapJoinedProps(root, prop.targetMeta, populate, qb, root, tmp, pivotMeta.className + '.' + pivotProp1.name);
|
|
741
|
+
return root;
|
|
742
|
+
});
|
|
743
|
+
// console.log(prop.name, prop.targetMeta!.className, items);
|
|
729
744
|
qb.clearRawFragmentsCache();
|
|
730
745
|
const map = {};
|
|
731
746
|
const pkProps = ownerMeta.getPrimaryProps();
|
|
732
|
-
|
|
747
|
+
for (const owner of owners) {
|
|
733
748
|
const key = core_1.Utils.getPrimaryKeyHash(prop.joinColumns.map((_col, idx) => {
|
|
734
749
|
const pkProp = pkProps[idx];
|
|
735
750
|
return pkProp.customType ? pkProp.customType.convertToJSValue(owner[idx], this.platform) : owner[idx];
|
|
736
751
|
}));
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
752
|
+
map[key] = [];
|
|
753
|
+
}
|
|
754
|
+
for (const item of items) {
|
|
740
755
|
const key = core_1.Utils.getPrimaryKeyHash(prop.joinColumns.map((col, idx) => {
|
|
741
756
|
const pkProp = pkProps[idx];
|
|
742
757
|
return pkProp.customType ? pkProp.customType.convertToJSValue(item[`fk__${col}`], this.platform) : item[`fk__${col}`];
|
|
@@ -746,7 +761,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
746
761
|
prop.inverseJoinColumns.forEach((col, idx) => {
|
|
747
762
|
core_1.Utils.renameKey(item, `fk__${col}`, prop.targetMeta.primaryKeys[idx]);
|
|
748
763
|
});
|
|
749
|
-
}
|
|
764
|
+
}
|
|
750
765
|
return map;
|
|
751
766
|
}
|
|
752
767
|
getPivotOrderBy(prop, pivotProp, pivotAlias, orderBy) {
|
|
@@ -784,13 +799,14 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
784
799
|
*/
|
|
785
800
|
joinedProps(meta, populate, options) {
|
|
786
801
|
return populate.filter(hint => {
|
|
787
|
-
const [propName] = hint.field.split(':', 2);
|
|
802
|
+
const [propName, ref] = hint.field.split(':', 2);
|
|
788
803
|
const prop = meta.properties[propName] || {};
|
|
789
804
|
if (hint.filter && hint.strategy === core_1.LoadStrategy.JOINED) {
|
|
790
805
|
return true;
|
|
791
806
|
}
|
|
792
807
|
if ((options?.strategy || hint.strategy || prop.strategy || this.config.get('loadStrategy')) !== core_1.LoadStrategy.JOINED) {
|
|
793
|
-
|
|
808
|
+
// force joined strategy for explicit 1:1 owner populate hint as it would require a join anyway
|
|
809
|
+
return prop.kind === core_1.ReferenceKind.ONE_TO_ONE && !prop.owner;
|
|
794
810
|
}
|
|
795
811
|
return ![core_1.ReferenceKind.SCALAR, core_1.ReferenceKind.EMBEDDED].includes(prop.kind);
|
|
796
812
|
});
|
|
@@ -861,6 +877,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
861
877
|
const prop = meta.properties[propName];
|
|
862
878
|
// ignore ref joins of known FKs unless it's a filter hint
|
|
863
879
|
if (ref && !hint.filter && (prop.kind === core_1.ReferenceKind.MANY_TO_ONE || (prop.kind === core_1.ReferenceKind.ONE_TO_ONE && !prop.owner))) {
|
|
880
|
+
// // console.log('wat', hint);
|
|
864
881
|
return;
|
|
865
882
|
}
|
|
866
883
|
const meta2 = this.metadata.find(prop.type);
|
|
@@ -894,9 +911,11 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
894
911
|
fields.push(...this.getFieldsForJoinedLoad(qb, meta2, childExplicitFields.length === 0 ? undefined : childExplicitFields, childExclude, hint.children, options, tableAlias, path));
|
|
895
912
|
}
|
|
896
913
|
else if (hint.filter) {
|
|
897
|
-
fields.push(field);
|
|
914
|
+
// fields.push(field);
|
|
915
|
+
fields.push(...prop.referencedColumnNames.map(col => qb.helper.mapper(`${tableAlias}.${col}`, qb.type, undefined, `${tableAlias}__${col}`)));
|
|
898
916
|
}
|
|
899
917
|
});
|
|
918
|
+
// // console.log(fields, joinedProps);
|
|
900
919
|
return fields;
|
|
901
920
|
}
|
|
902
921
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.1.10-dev.
|
|
3
|
+
"version": "6.1.10-dev.3",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.1.9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.1.10-dev.
|
|
69
|
+
"@mikro-orm/core": "6.1.10-dev.3"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/query/QueryBuilder.js
CHANGED
|
@@ -1072,6 +1072,7 @@ class QueryBuilder {
|
|
|
1072
1072
|
const alias = this.getNextAlias(prop.pivotEntity ?? prop.type);
|
|
1073
1073
|
const aliasedName = `${fromAlias}.${prop.name}#${alias}`;
|
|
1074
1074
|
this._joins[aliasedName] = this.helper.joinOneToReference(prop, this.mainAlias.aliasName, alias, enums_1.JoinType.leftJoin);
|
|
1075
|
+
this._joins[aliasedName].path = `${(Object.values(this._joins).find(j => j.alias === fromAlias)?.path ?? meta.className)}.${prop.name}`;
|
|
1075
1076
|
this._populateMap[aliasedName] = this._joins[aliasedName].alias;
|
|
1076
1077
|
}
|
|
1077
1078
|
});
|
|
@@ -1131,6 +1132,10 @@ class QueryBuilder {
|
|
|
1131
1132
|
if (join.cond[k]) {
|
|
1132
1133
|
join.cond = { [op ?? '$and']: [join.cond, { [k]: cond[k] }] };
|
|
1133
1134
|
}
|
|
1135
|
+
else if (op === '$or') {
|
|
1136
|
+
join.cond.$or ??= [];
|
|
1137
|
+
join.cond.$or.push({ [k]: cond[k] });
|
|
1138
|
+
}
|
|
1134
1139
|
else {
|
|
1135
1140
|
join.cond = { ...join.cond, [k]: cond[k] };
|
|
1136
1141
|
}
|
|
@@ -193,8 +193,10 @@ class QueryBuilderHelper {
|
|
|
193
193
|
conditions.push(`${left} = ${this.knex.ref(right)}`);
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
|
-
const left =
|
|
197
|
-
|
|
196
|
+
const left = join.prop.object && join.prop.fieldNameRaw
|
|
197
|
+
? join.prop.fieldNameRaw.replaceAll(core_1.ALIAS_REPLACEMENT, join.ownerAlias)
|
|
198
|
+
: this.knex.ref(`${join.ownerAlias}.${primaryKey}`);
|
|
199
|
+
conditions.push(`${left} = ${this.knex.ref(right)}`);
|
|
198
200
|
});
|
|
199
201
|
}
|
|
200
202
|
if (join.prop.targetMeta?.discriminatorValue && !join.path?.endsWith('[pivot]')) {
|
|
@@ -295,7 +297,7 @@ class QueryBuilderHelper {
|
|
|
295
297
|
if (join.prop && [core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(join.prop.kind)) {
|
|
296
298
|
return join.prop.fieldNames.map((fieldName, idx) => {
|
|
297
299
|
const columns = join.prop.owner ? join.joinColumns : join.inverseJoinColumns;
|
|
298
|
-
return this.mapper(`${join.alias}.${columns[idx]}`, type, undefined,
|
|
300
|
+
return this.mapper(`${join.alias}.${columns[idx]}`, type, undefined, `${join.alias}__${columns[idx]}`);
|
|
299
301
|
});
|
|
300
302
|
}
|
|
301
303
|
return [
|
|
@@ -16,9 +16,23 @@ export declare class DatabaseSchema {
|
|
|
16
16
|
getTables(): DatabaseTable[];
|
|
17
17
|
getTable(name: string): DatabaseTable | undefined;
|
|
18
18
|
hasTable(name: string): boolean;
|
|
19
|
-
setNativeEnums(nativeEnums: Dictionary<
|
|
20
|
-
|
|
19
|
+
setNativeEnums(nativeEnums: Dictionary<{
|
|
20
|
+
name: string;
|
|
21
|
+
schema?: string;
|
|
22
|
+
items: string[];
|
|
23
|
+
}>): void;
|
|
24
|
+
getNativeEnums(): Dictionary<{
|
|
25
|
+
name: string;
|
|
26
|
+
schema?: string;
|
|
27
|
+
items: string[];
|
|
28
|
+
}>;
|
|
29
|
+
getNativeEnum(name: string): {
|
|
30
|
+
name: string;
|
|
31
|
+
schema?: string;
|
|
32
|
+
items: string[];
|
|
33
|
+
};
|
|
21
34
|
hasNamespace(namespace: string): boolean;
|
|
35
|
+
hasNativeEnum(name: string): boolean;
|
|
22
36
|
getNamespaces(): string[];
|
|
23
37
|
static create(connection: AbstractSqlConnection, platform: AbstractSqlPlatform, config: Configuration, schemaName?: string, schemas?: string[]): Promise<DatabaseSchema>;
|
|
24
38
|
static fromMetadata(metadata: EntityMetadata[], platform: AbstractSqlPlatform, config: Configuration, schemaName?: string): DatabaseSchema;
|
package/schema/DatabaseSchema.js
CHANGED
|
@@ -43,9 +43,15 @@ class DatabaseSchema {
|
|
|
43
43
|
getNativeEnums() {
|
|
44
44
|
return this.nativeEnums;
|
|
45
45
|
}
|
|
46
|
+
getNativeEnum(name) {
|
|
47
|
+
return this.nativeEnums[name];
|
|
48
|
+
}
|
|
46
49
|
hasNamespace(namespace) {
|
|
47
50
|
return this.namespaces.has(namespace);
|
|
48
51
|
}
|
|
52
|
+
hasNativeEnum(name) {
|
|
53
|
+
return name in this.nativeEnums;
|
|
54
|
+
}
|
|
49
55
|
getNamespaces() {
|
|
50
56
|
return [...this.namespaces];
|
|
51
57
|
}
|
|
@@ -63,9 +69,20 @@ class DatabaseSchema {
|
|
|
63
69
|
const schema = new DatabaseSchema(platform, schemaName ?? config.get('schema'));
|
|
64
70
|
const nativeEnums = {};
|
|
65
71
|
for (const meta of metadata) {
|
|
66
|
-
meta.props
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
for (const prop of meta.props) {
|
|
73
|
+
if (prop.nativeEnumName) {
|
|
74
|
+
let key = prop.nativeEnumName;
|
|
75
|
+
const s = meta.schema ?? schema.name;
|
|
76
|
+
if (s && s !== platform.getDefaultSchemaName()) {
|
|
77
|
+
key = s + '.' + key;
|
|
78
|
+
}
|
|
79
|
+
nativeEnums[key] = {
|
|
80
|
+
name: prop.nativeEnumName,
|
|
81
|
+
schema: meta.schema ?? schema.name,
|
|
82
|
+
items: prop.items?.map(val => '' + val) ?? [],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
69
86
|
}
|
|
70
87
|
schema.setNativeEnums(nativeEnums);
|
|
71
88
|
for (const meta of metadata) {
|
|
@@ -13,7 +13,11 @@ export declare class DatabaseTable {
|
|
|
13
13
|
private indexes;
|
|
14
14
|
private checks;
|
|
15
15
|
private foreignKeys;
|
|
16
|
-
nativeEnums: Dictionary<
|
|
16
|
+
nativeEnums: Dictionary<{
|
|
17
|
+
name: string;
|
|
18
|
+
schema?: string;
|
|
19
|
+
items: string[];
|
|
20
|
+
}>;
|
|
17
21
|
comment?: string;
|
|
18
22
|
constructor(platform: AbstractSqlPlatform, name: string, schema?: string | undefined);
|
|
19
23
|
getColumns(): Column[];
|
|
@@ -23,7 +23,17 @@ class SchemaComparator {
|
|
|
23
23
|
* stored in toSchema.
|
|
24
24
|
*/
|
|
25
25
|
compare(fromSchema, toSchema, inverseDiff) {
|
|
26
|
-
const diff = {
|
|
26
|
+
const diff = {
|
|
27
|
+
newTables: {},
|
|
28
|
+
removedTables: {},
|
|
29
|
+
changedTables: {},
|
|
30
|
+
orphanedForeignKeys: [],
|
|
31
|
+
newNativeEnums: [],
|
|
32
|
+
removedNativeEnums: [],
|
|
33
|
+
newNamespaces: new Set(),
|
|
34
|
+
removedNamespaces: new Set(),
|
|
35
|
+
fromSchema,
|
|
36
|
+
};
|
|
27
37
|
const foreignKeysToTable = {};
|
|
28
38
|
for (const namespace of toSchema.getNamespaces()) {
|
|
29
39
|
if (fromSchema.hasNamespace(namespace) || namespace === this.platform.getDefaultSchemaName()) {
|
|
@@ -37,6 +47,18 @@ class SchemaComparator {
|
|
|
37
47
|
}
|
|
38
48
|
diff.removedNamespaces.add(namespace);
|
|
39
49
|
}
|
|
50
|
+
for (const nativeEnum of Object.keys(toSchema.getNativeEnums())) {
|
|
51
|
+
if (fromSchema.hasNativeEnum(nativeEnum)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
diff.newNativeEnums.push(toSchema.getNativeEnum(nativeEnum));
|
|
55
|
+
}
|
|
56
|
+
for (const nativeEnum of Object.keys(fromSchema.getNativeEnums())) {
|
|
57
|
+
if (toSchema.hasNativeEnum(nativeEnum)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
diff.removedNativeEnums.push(fromSchema.getNativeEnum(nativeEnum));
|
|
61
|
+
}
|
|
40
62
|
for (const table of toSchema.getTables()) {
|
|
41
63
|
const tableName = table.getShortestName();
|
|
42
64
|
if (!fromSchema.hasTable(tableName)) {
|
|
@@ -68,7 +68,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
70
70
|
created.push(enumName);
|
|
71
|
-
const sql = this.helper.getCreateNativeEnumSQL(enumName, enumOptions, options.schema ?? this.config.get('schema'));
|
|
71
|
+
const sql = this.helper.getCreateNativeEnumSQL(enumName, enumOptions.items, options.schema ?? this.config.get('schema'));
|
|
72
72
|
ret += await this.dump(this.knex.schema.raw(sql), '\n');
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -180,7 +180,6 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
180
180
|
const wildcardSchemaTables = Object.values(this.metadata.getAll()).filter(meta => meta.schema === '*').map(meta => meta.tableName);
|
|
181
181
|
fromSchema.prune(options.schema, wildcardSchemaTables);
|
|
182
182
|
toSchema.prune(options.schema, wildcardSchemaTables);
|
|
183
|
-
toSchema.setNativeEnums(fromSchema.getNativeEnums());
|
|
184
183
|
return { fromSchema, toSchema };
|
|
185
184
|
}
|
|
186
185
|
async diffToSQL(schemaDiff, options) {
|
|
@@ -191,6 +190,12 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
191
190
|
ret += await this.dump(this.knex.schema.createSchemaIfNotExists(newNamespace));
|
|
192
191
|
}
|
|
193
192
|
}
|
|
193
|
+
if (this.platform.supportsNativeEnums()) {
|
|
194
|
+
for (const newNativeEnum of schemaDiff.newNativeEnums) {
|
|
195
|
+
const sql = this.helper.getCreateNativeEnumSQL(newNativeEnum.name, newNativeEnum.items, newNativeEnum.schema ?? options.schema ?? this.config.get('schema'));
|
|
196
|
+
ret += await this.dump(this.knex.schema.raw(sql), '\n');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
194
199
|
if (!options.safe) {
|
|
195
200
|
for (const orphanedForeignKey of schemaDiff.orphanedForeignKeys) {
|
|
196
201
|
const [schemaName, tableName] = this.splitTableName(orphanedForeignKey.localTableName);
|
|
@@ -227,6 +232,12 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
227
232
|
ret += await this.dump(builder);
|
|
228
233
|
}
|
|
229
234
|
}
|
|
235
|
+
if (!options.safe && this.platform.supportsNativeEnums()) {
|
|
236
|
+
for (const removedNativeEnum of schemaDiff.removedNativeEnums) {
|
|
237
|
+
const sql = this.helper.getDropNativeEnumSQL(removedNativeEnum.name, removedNativeEnum.schema);
|
|
238
|
+
ret += await this.dump(this.knex.schema.raw(sql), '\n');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
230
241
|
if (options.dropTables && !options.safe) {
|
|
231
242
|
for (const removedNamespace of schemaDiff.removedNamespaces) {
|
|
232
243
|
ret += await this.dump(this.knex.schema.dropSchema(removedNamespace));
|
|
@@ -296,22 +307,16 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
296
307
|
const ret = [];
|
|
297
308
|
const [schemaName, tableName] = this.splitTableName(diff.name);
|
|
298
309
|
if (this.platform.supportsNativeEnums()) {
|
|
299
|
-
const createdNativeEnums = [];
|
|
300
310
|
const changedNativeEnums = [];
|
|
301
|
-
for (const { column, changedProperties
|
|
311
|
+
for (const { column, changedProperties } of Object.values(diff.changedColumns)) {
|
|
302
312
|
if (!column.nativeEnumName) {
|
|
303
313
|
continue;
|
|
304
314
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
else if (changedProperties.has('type') && !(column.nativeEnumName in diff.fromTable.nativeEnums)) {
|
|
309
|
-
createdNativeEnums.push([column.nativeEnumName, column.enumItems]);
|
|
315
|
+
const key = schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' + column.nativeEnumName : column.nativeEnumName;
|
|
316
|
+
if (changedProperties.has('enumItems') && key in diff.fromTable.nativeEnums) {
|
|
317
|
+
changedNativeEnums.push([column.nativeEnumName, column.enumItems, diff.fromTable.nativeEnums[key].items]);
|
|
310
318
|
}
|
|
311
319
|
}
|
|
312
|
-
core_1.Utils.removeDuplicates(createdNativeEnums).forEach(([enumName, items]) => {
|
|
313
|
-
ret.push(this.knex.schema.raw(this.helper.getCreateNativeEnumSQL(enumName, items, schemaName)));
|
|
314
|
-
});
|
|
315
320
|
core_1.Utils.removeDuplicates(changedNativeEnums).forEach(([enumName, itemsNew, itemsOld]) => {
|
|
316
321
|
// postgres allows only adding new items, the values are case insensitive
|
|
317
322
|
itemsOld = itemsOld.map(v => v.toLowerCase());
|
package/typings.d.ts
CHANGED
|
@@ -107,10 +107,19 @@ export interface TableDifference {
|
|
|
107
107
|
}
|
|
108
108
|
export interface SchemaDifference {
|
|
109
109
|
newNamespaces: Set<string>;
|
|
110
|
+
newNativeEnums: {
|
|
111
|
+
name: string;
|
|
112
|
+
schema?: string;
|
|
113
|
+
items: string[];
|
|
114
|
+
}[];
|
|
110
115
|
newTables: Dictionary<DatabaseTable>;
|
|
111
116
|
changedTables: Dictionary<TableDifference>;
|
|
112
117
|
removedTables: Dictionary<DatabaseTable>;
|
|
113
118
|
removedNamespaces: Set<string>;
|
|
119
|
+
removedNativeEnums: {
|
|
120
|
+
name: string;
|
|
121
|
+
schema?: string;
|
|
122
|
+
}[];
|
|
114
123
|
orphanedForeignKeys: ForeignKey[];
|
|
115
124
|
fromSchema: DatabaseSchema;
|
|
116
125
|
}
|