@mikro-orm/core 7.0.8-dev.3 → 7.0.8-dev.5
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/entity/EntityHelper.js +4 -2
- package/package.json +1 -1
- package/unit-of-work/UnitOfWork.js +7 -1
- package/utils/Utils.js +1 -1
package/entity/EntityHelper.js
CHANGED
|
@@ -228,7 +228,8 @@ export class EntityHelper {
|
|
|
228
228
|
// Inverse already points to owner — propagation is not needed,
|
|
229
229
|
// but we still need to clean up old's inverse side.
|
|
230
230
|
helper(old).__pk ??= helper(old).getPrimaryKey();
|
|
231
|
-
if
|
|
231
|
+
// Don't nullify the FK if it's part of the PK — the entity will be deleted via orphan removal
|
|
232
|
+
if (old[prop2.name] != null && !(prop.orphanRemoval && prop2.primary)) {
|
|
232
233
|
delete helper(old).__data[prop2.name];
|
|
233
234
|
old[prop2.name] = null;
|
|
234
235
|
}
|
|
@@ -267,7 +268,8 @@ export class EntityHelper {
|
|
|
267
268
|
else {
|
|
268
269
|
entity[prop2.name] = Reference.wrapReference(owner, prop);
|
|
269
270
|
}
|
|
270
|
-
if
|
|
271
|
+
// Don't nullify the FK if it's part of the PK — the entity will be deleted via orphan removal
|
|
272
|
+
if (old?.[prop2.name] != null && !(prop.orphanRemoval && prop2.primary)) {
|
|
271
273
|
delete helper(old).__data[prop2.name];
|
|
272
274
|
old[prop2.name] = null;
|
|
273
275
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.8-dev.
|
|
3
|
+
"version": "7.0.8-dev.5",
|
|
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",
|
|
@@ -967,7 +967,13 @@ export class UnitOfWork {
|
|
|
967
967
|
}
|
|
968
968
|
await this.#changeSetPersister.executeInserts(changeSets, { ctx });
|
|
969
969
|
for (const changeSet of changeSets) {
|
|
970
|
-
|
|
970
|
+
// For TPT entities, use the full entity snapshot instead of the partial changeset payload,
|
|
971
|
+
// since each table's changeset only contains its own properties. Without this, the snapshot
|
|
972
|
+
// would only have the last table's properties, causing spurious UPDATEs on next flush (GH #7454).
|
|
973
|
+
const data = changeSet.meta.inheritanceType === 'tpt'
|
|
974
|
+
? this.#comparator.prepareEntity(changeSet.entity)
|
|
975
|
+
: changeSet.payload;
|
|
976
|
+
this.register(changeSet.entity, data, { refresh: true });
|
|
971
977
|
await this.runHooks(EventType.afterCreate, changeSet);
|
|
972
978
|
}
|
|
973
979
|
}
|
package/utils/Utils.js
CHANGED
|
@@ -132,7 +132,7 @@ export function parseJsonSafe(value) {
|
|
|
132
132
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
133
133
|
export class Utils {
|
|
134
134
|
static PK_SEPARATOR = '~~~';
|
|
135
|
-
static #ORM_VERSION = '7.0.8-dev.
|
|
135
|
+
static #ORM_VERSION = '7.0.8-dev.5';
|
|
136
136
|
/**
|
|
137
137
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
138
138
|
*/
|