@mikro-orm/core 7.0.0-dev.152 → 7.0.0-dev.153
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/metadata/EntitySchema.js +11 -2
- package/metadata/MetadataDiscovery.js +2 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/metadata/EntitySchema.js
CHANGED
|
@@ -151,7 +151,8 @@ export class EntitySchema {
|
|
|
151
151
|
this._meta.extends = base;
|
|
152
152
|
}
|
|
153
153
|
setClass(cls) {
|
|
154
|
-
const
|
|
154
|
+
const oldClass = this._meta.class;
|
|
155
|
+
const sameClass = this._meta.class === cls;
|
|
155
156
|
this._meta.class = cls;
|
|
156
157
|
this._meta.prototype = cls.prototype;
|
|
157
158
|
this._meta.className = this._meta.name ?? cls.name;
|
|
@@ -159,10 +160,18 @@ export class EntitySchema {
|
|
|
159
160
|
this._meta.constructorParams = Utils.getConstructorParams(cls);
|
|
160
161
|
}
|
|
161
162
|
if (!this.internal) {
|
|
163
|
+
// Remove old class from registry if it's being replaced with a different class
|
|
164
|
+
if (oldClass && oldClass !== cls && EntitySchema.REGISTRY.get(oldClass) === this) {
|
|
165
|
+
EntitySchema.REGISTRY.delete(oldClass);
|
|
166
|
+
}
|
|
162
167
|
EntitySchema.REGISTRY.set(cls, this);
|
|
163
168
|
}
|
|
164
169
|
const base = Object.getPrototypeOf(cls);
|
|
165
|
-
if
|
|
170
|
+
// Only set extends if the parent is NOT the auto-generated class for this same entity.
|
|
171
|
+
// When the user extends the auto-generated class (from defineEntity without a class option)
|
|
172
|
+
// and registers their custom class via setClass, we don't want to discover the
|
|
173
|
+
// auto-generated class as a separate parent entity.
|
|
174
|
+
if (base !== BaseEntity && base.name !== this._meta.className) {
|
|
166
175
|
this._meta.extends ??= base.name ? base : undefined;
|
|
167
176
|
}
|
|
168
177
|
}
|
|
@@ -241,7 +241,8 @@ export class MetadataDiscovery {
|
|
|
241
241
|
continue;
|
|
242
242
|
}
|
|
243
243
|
parent = Object.getPrototypeOf(meta.class);
|
|
244
|
-
if
|
|
244
|
+
// Skip if parent is the auto-generated base class for the same entity (from setClass usage)
|
|
245
|
+
if (parent.name !== '' && parent.name !== meta.className && !this.metadata.has(parent) && parent !== BaseEntity) {
|
|
245
246
|
this.discoverReferences([parent], false);
|
|
246
247
|
}
|
|
247
248
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.153",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.153';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|