@mikro-orm/core 6.4.17-dev.5 → 6.4.17-dev.7
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.
|
@@ -37,4 +37,6 @@ export interface ManyToManyOptions<Owner, Target> extends ReferenceOptions<Owner
|
|
|
37
37
|
deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
38
38
|
/** What to do when the reference to the target entity gets updated. */
|
|
39
39
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
40
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
41
|
+
createForeignKeyConstraint?: boolean;
|
|
40
42
|
}
|
|
@@ -27,6 +27,8 @@ export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner,
|
|
|
27
27
|
updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
|
|
28
28
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
29
29
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
30
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
31
|
+
createForeignKeyConstraint?: boolean;
|
|
30
32
|
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
31
33
|
foreignKeyName?: string;
|
|
32
34
|
}
|
package/decorators/OneToOne.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ export interface OneToOneOptions<Owner, Target> extends Partial<Omit<OneToManyOp
|
|
|
23
23
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
24
24
|
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
25
25
|
foreignKeyName?: string;
|
|
26
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
27
|
+
createForeignKeyConstraint?: boolean;
|
|
26
28
|
}
|
package/metadata/EntitySchema.js
CHANGED
|
@@ -102,6 +102,8 @@ class EntitySchema {
|
|
|
102
102
|
if (prop.fieldNames && !prop.joinColumns) {
|
|
103
103
|
prop.joinColumns = prop.fieldNames;
|
|
104
104
|
}
|
|
105
|
+
// By default, the foreign key constraint is created on the relation
|
|
106
|
+
utils_1.Utils.defaultValue(prop, 'createForeignKeyConstraint', true);
|
|
105
107
|
this.addProperty(name, type, prop);
|
|
106
108
|
}
|
|
107
109
|
addManyToMany(name, type, options) {
|
|
@@ -111,6 +113,8 @@ class EntitySchema {
|
|
|
111
113
|
}
|
|
112
114
|
if (options.owner) {
|
|
113
115
|
utils_1.Utils.renameKey(options, 'mappedBy', 'inversedBy');
|
|
116
|
+
// By default, the foreign key constraint is created on the relation
|
|
117
|
+
utils_1.Utils.defaultValue(options, 'createForeignKeyConstraint', true);
|
|
114
118
|
}
|
|
115
119
|
const prop = this.createProperty(enums_1.ReferenceKind.MANY_TO_MANY, options);
|
|
116
120
|
this.addProperty(name, type, prop);
|
|
@@ -123,8 +127,12 @@ class EntitySchema {
|
|
|
123
127
|
const prop = this.createProperty(enums_1.ReferenceKind.ONE_TO_ONE, options);
|
|
124
128
|
utils_1.Utils.defaultValue(prop, 'owner', !!prop.inversedBy || !prop.mappedBy);
|
|
125
129
|
utils_1.Utils.defaultValue(prop, 'unique', prop.owner);
|
|
126
|
-
if (prop.owner
|
|
127
|
-
|
|
130
|
+
if (prop.owner) {
|
|
131
|
+
if (options.mappedBy) {
|
|
132
|
+
utils_1.Utils.renameKey(prop, 'mappedBy', 'inversedBy');
|
|
133
|
+
}
|
|
134
|
+
// By default, the foreign key constraint is created on the relation
|
|
135
|
+
utils_1.Utils.defaultValue(prop, 'createForeignKeyConstraint', true);
|
|
128
136
|
}
|
|
129
137
|
if (prop.joinColumns && !prop.fieldNames) {
|
|
130
138
|
prop.fieldNames = prop.joinColumns;
|
|
@@ -657,6 +657,7 @@ class MetadataDiscovery {
|
|
|
657
657
|
autoincrement: false,
|
|
658
658
|
updateRule: prop.updateRule,
|
|
659
659
|
deleteRule: prop.deleteRule,
|
|
660
|
+
createForeignKeyConstraint: prop.createForeignKeyConstraint,
|
|
660
661
|
};
|
|
661
662
|
if (selfReferencing && !this.platform.supportsMultipleCascadePaths()) {
|
|
662
663
|
ret.updateRule ??= 'no action';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.17-dev.
|
|
3
|
+
"version": "6.4.17-dev.7",
|
|
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",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.4.17-dev.
|
|
67
|
+
"mikro-orm": "6.4.17-dev.7",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/typings.d.ts
CHANGED
|
@@ -384,6 +384,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
384
384
|
optional?: boolean;
|
|
385
385
|
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
386
386
|
deferMode?: DeferMode;
|
|
387
|
+
createForeignKeyConstraint: boolean;
|
|
387
388
|
foreignKeyName?: string;
|
|
388
389
|
}
|
|
389
390
|
export declare class EntityMetadata<T = any> {
|