@mikro-orm/core 7.1.4-dev.0 → 7.1.4-dev.1
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/MetadataDiscovery.js +3 -1
- package/package.json +1 -1
- package/utils/EntityComparator.js +19 -1
- package/utils/Utils.js +1 -1
|
@@ -1391,7 +1391,9 @@ export class MetadataDiscovery {
|
|
|
1391
1391
|
meta.root.uniques.push({ properties });
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
|
|
1394
|
+
// The primary key column is shared by every subtype, so it stays NOT NULL —
|
|
1395
|
+
// only subtype-specific columns become nullable for the rows of other subtypes.
|
|
1396
|
+
newProp.nullable = !newProp.primary;
|
|
1395
1397
|
newProp.inherited = !rootProp;
|
|
1396
1398
|
// For narrowed relation overrides, keep the root's declaration intact so
|
|
1397
1399
|
// the full target union (e.g. `Food`) is preserved for populates from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.1.4-dev.
|
|
3
|
+
"version": "7.1.4-dev.1",
|
|
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",
|
|
@@ -393,7 +393,25 @@ export class EntityComparator {
|
|
|
393
393
|
else {
|
|
394
394
|
mapEntityProperties(meta);
|
|
395
395
|
}
|
|
396
|
-
|
|
396
|
+
// pass through any unmapped columns (e.g. extra selections or virtual props). for embeddables we restrict
|
|
397
|
+
// this to declared keys, otherwise JSON keys not part of the schema leak into the original data while
|
|
398
|
+
// hydration drops them from the entity, diverging the snapshot and triggering spurious updates.
|
|
399
|
+
let knownKeysGuard = '';
|
|
400
|
+
if (meta.embeddable) {
|
|
401
|
+
const knownKeys = new Set();
|
|
402
|
+
for (const m of meta.polymorphs?.length ? meta.polymorphs : [meta]) {
|
|
403
|
+
for (const prop of m.props) {
|
|
404
|
+
knownKeys.add(prop.name);
|
|
405
|
+
if (prop.embedded) {
|
|
406
|
+
knownKeys.add(prop.embedded[1]);
|
|
407
|
+
}
|
|
408
|
+
prop.fieldNames?.forEach(field => knownKeys.add(field));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
context.set('knownKeys', knownKeys);
|
|
412
|
+
knownKeysGuard = ' && knownKeys.has(k)';
|
|
413
|
+
}
|
|
414
|
+
lines.push(` for (let k in result) { if (Object.hasOwn(result, k) && !mapped[k] && ret[k] === undefined${knownKeysGuard}) ret[k] = result[k]; }`);
|
|
397
415
|
const code = `// compiled mapper for entity ${meta.className}\n` +
|
|
398
416
|
`return function(result) {\n const ret = {};\n${lines.join('\n')}\n return ret;\n}`;
|
|
399
417
|
const fnKey = `resultMapper-${meta.uniqueName}`;
|
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.4-dev.
|
|
144
|
+
static #ORM_VERSION = '7.1.4-dev.1';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|