@mikro-orm/core 7.1.0-dev.22 → 7.1.0-dev.23
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/EntityManager.js
CHANGED
|
@@ -1179,9 +1179,6 @@ export class EntityManager {
|
|
|
1179
1179
|
helper(data).setSchema(options.schema);
|
|
1180
1180
|
}
|
|
1181
1181
|
if (!helper(data).__managed) {
|
|
1182
|
-
// the entity might have been created via `em.create()`, which adds it to the persist stack automatically
|
|
1183
|
-
em.#unitOfWork.getPersistStack().delete(data);
|
|
1184
|
-
// it can be also in the identity map if it had a PK value already
|
|
1185
1182
|
em.#unitOfWork.unsetIdentity(data);
|
|
1186
1183
|
}
|
|
1187
1184
|
const meta = helper(data).__meta;
|
|
@@ -1270,9 +1267,6 @@ export class EntityManager {
|
|
|
1270
1267
|
helper(row).setSchema(options.schema);
|
|
1271
1268
|
}
|
|
1272
1269
|
if (!helper(row).__managed) {
|
|
1273
|
-
// the entity might have been created via `em.create()`, which adds it to the persist stack automatically
|
|
1274
|
-
em.#unitOfWork.getPersistStack().delete(row);
|
|
1275
|
-
// it can be also in the identity map if it had a PK value already
|
|
1276
1270
|
em.#unitOfWork.unsetIdentity(row);
|
|
1277
1271
|
}
|
|
1278
1272
|
const payload = em.#comparator.prepareEntity(row);
|
|
@@ -1268,7 +1268,10 @@ export class MetadataDiscovery {
|
|
|
1268
1268
|
if (!rootProp || rootProp.kind !== prop.kind) {
|
|
1269
1269
|
return false;
|
|
1270
1270
|
}
|
|
1271
|
-
if (prop.kind !== ReferenceKind.MANY_TO_ONE &&
|
|
1271
|
+
if (prop.kind !== ReferenceKind.MANY_TO_ONE &&
|
|
1272
|
+
prop.kind !== ReferenceKind.ONE_TO_ONE &&
|
|
1273
|
+
prop.kind !== ReferenceKind.ONE_TO_MANY &&
|
|
1274
|
+
prop.kind !== ReferenceKind.MANY_TO_MANY) {
|
|
1272
1275
|
return false;
|
|
1273
1276
|
}
|
|
1274
1277
|
const aRoot = this.#metadata.getByClassName(prop.type, false)?.root;
|
|
@@ -1324,7 +1327,14 @@ export class MetadataDiscovery {
|
|
|
1324
1327
|
// cleared implicitly when the first child claims the root property via
|
|
1325
1328
|
// addProperty below, so subsequent children correctly trigger renaming.
|
|
1326
1329
|
const typesMatch = rootProp?.type === prop.type || rootProp?.stiMerged === true || narrowedRelationOverride;
|
|
1330
|
+
// Inverse-side relations (1:m, inverse m:n) have no FK column on this
|
|
1331
|
+
// entity, so the rename branch — which exists to disambiguate physical
|
|
1332
|
+
// columns shared across STI children — doesn't apply. Skipping it also
|
|
1333
|
+
// avoids crashing on `[...rootProp.fieldNames]` since fieldNames is
|
|
1334
|
+
// never populated for inverse-side properties.
|
|
1335
|
+
const isInverseSideRelation = prop.kind === ReferenceKind.ONE_TO_MANY || (prop.kind === ReferenceKind.MANY_TO_MANY && !prop.owner);
|
|
1327
1336
|
if (rootProp &&
|
|
1337
|
+
!isInverseSideRelation &&
|
|
1328
1338
|
(!typesMatch ||
|
|
1329
1339
|
(rootProp.fieldNames && prop.fieldNames && !compareArrays(rootProp.fieldNames, prop.fieldNames)))) {
|
|
1330
1340
|
const name = newProp.name;
|
|
@@ -1379,6 +1389,14 @@ export class MetadataDiscovery {
|
|
|
1379
1389
|
if (narrowedRelationOverride) {
|
|
1380
1390
|
return;
|
|
1381
1391
|
}
|
|
1392
|
+
// STI siblings can declare the same property name on inverse-side relations
|
|
1393
|
+
// pointing to disjoint targets (e.g. `Dog.items → DogItem` and
|
|
1394
|
+
// `Cat.items → CatItem` with no shared base). There's no physical column
|
|
1395
|
+
// to manage at root, and propagating would clobber the first child's
|
|
1396
|
+
// declaration; each child keeps its local typed property instead.
|
|
1397
|
+
if (isInverseSideRelation && rootProp && rootProp.type !== prop.type) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1382
1400
|
meta.root.addProperty(newProp);
|
|
1383
1401
|
});
|
|
1384
1402
|
meta.tableName = meta.root.tableName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.23",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -16,7 +16,8 @@ function isVisible(meta, propName, options) {
|
|
|
16
16
|
if (Array.isArray(options.fields) && options.fields.length > 0 && !matchesPath(options.fields, propName)) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
if (Array.isArray(options.populate) &&
|
|
19
|
+
if (Array.isArray(options.populate) &&
|
|
20
|
+
options.populate.find(item => item === propName || item.startsWith(propName + '.'))) {
|
|
20
21
|
return true;
|
|
21
22
|
}
|
|
22
23
|
if (options.exclude?.find(item => item === propName)) {
|
|
@@ -474,6 +474,9 @@ export class UnitOfWork {
|
|
|
474
474
|
}
|
|
475
475
|
unsetIdentity(entity) {
|
|
476
476
|
this.#identityMap.delete(entity);
|
|
477
|
+
this.#persistStack.delete(entity);
|
|
478
|
+
this.#removeStack.delete(entity);
|
|
479
|
+
this.#orphanRemoveStack.delete(entity);
|
|
477
480
|
const wrapped = helper(entity);
|
|
478
481
|
const serializedPK = wrapped.getSerializedPrimaryKey();
|
|
479
482
|
// remove references of this entity in all managed entities, otherwise flushing could reinsert the entity
|
package/utils/Utils.js
CHANGED
|
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
|
|
|
141
141
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
142
142
|
export class Utils {
|
|
143
143
|
static PK_SEPARATOR = '~~~';
|
|
144
|
-
static #ORM_VERSION = '7.1.0-dev.
|
|
144
|
+
static #ORM_VERSION = '7.1.0-dev.23';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|