@mikro-orm/core 7.2.5-dev.8 → 7.2.5-dev.9
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/package.json +1 -1
- package/utils/EntityComparator.js +10 -2
- package/utils/Utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.5-dev.
|
|
3
|
+
"version": "7.2.5-dev.9",
|
|
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",
|
|
@@ -366,8 +366,16 @@ export class EntityComparator {
|
|
|
366
366
|
if (prop.renamedFrom) {
|
|
367
367
|
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
368
368
|
defined = `${this.propName(prop.fieldNames[0])} != null`;
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
const sharesColumn = meta.props.some(p => p !== prop && p.name === prop.name && p.fieldNames?.[0] === prop.fieldNames[0]);
|
|
370
|
+
// hydrators expect mapped embeddable keys, so a shared object embeddable is mapped only for its own subtypes
|
|
371
|
+
if (sharesColumn && prop.kind === ReferenceKind.EMBEDDED && prop.object && meta.discriminatorMap) {
|
|
372
|
+
const owners = Object.entries(meta.discriminatorMap)
|
|
373
|
+
.filter(([, cls]) => this.#metadata.find(cls)?.properties[prop.name]?.targetMeta === prop.targetMeta)
|
|
374
|
+
.map(([value]) => `${this.propName(meta.discriminatorColumn)} == ${JSON.stringify(value)}`);
|
|
375
|
+
defined += ` && (${owners.join(' || ')})`;
|
|
376
|
+
}
|
|
377
|
+
else if (sharesColumn) {
|
|
378
|
+
// a column shared with a differently typed subtype is left for each subtype's hydrator to convert
|
|
371
379
|
lines.push(`${padding} if (${defined}) {`);
|
|
372
380
|
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])};`);
|
|
373
381
|
lines.push(`${padding} }`);
|
package/utils/Utils.js
CHANGED
|
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
|
|
|
153
153
|
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
154
154
|
export class Utils {
|
|
155
155
|
static PK_SEPARATOR = '~~~';
|
|
156
|
-
static #ORM_VERSION = '7.2.5-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.5-dev.9';
|
|
157
157
|
/** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
|
|
158
158
|
static getRlsSettingName(filterName, argName) {
|
|
159
159
|
return `mikro.${filterName}.${argName}`;
|