@mikro-orm/core 7.2.2-dev.29 → 7.2.2-dev.30
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 +2 -1
- package/package.json +1 -1
- package/utils/EntityComparator.js +17 -4
- package/utils/Utils.js +1 -1
|
@@ -1460,7 +1460,8 @@ export class MetadataDiscovery {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
1462
|
rootProp.stiFieldNameMap[meta.discriminatorValue] = prop.fieldNames[0];
|
|
1463
|
-
|
|
1463
|
+
// subtypes that only differ in type share the column
|
|
1464
|
+
rootProp.stiFieldNames = Utils.unique([...rootProp.stiFieldNames, ...prop.fieldNames]);
|
|
1464
1465
|
newProp.nullable = true;
|
|
1465
1466
|
newProp.name = name;
|
|
1466
1467
|
newProp.hydrate = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.2-dev.
|
|
3
|
+
"version": "7.2.2-dev.30",
|
|
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",
|
|
@@ -350,14 +350,27 @@ export class EntityComparator {
|
|
|
350
350
|
if (prop.embedded && (meta.embeddable || meta.properties[prop.embedded[0]].object)) {
|
|
351
351
|
continue;
|
|
352
352
|
}
|
|
353
|
+
let defined = `typeof ${this.propName(prop.fieldNames[0])} !== 'undefined'`;
|
|
354
|
+
// STI subtypes with conflicting columns share the property, so another subtype's null column must not override it
|
|
355
|
+
if (prop.renamedFrom) {
|
|
356
|
+
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
357
|
+
defined = `${this.propName(prop.fieldNames[0])} != null`;
|
|
358
|
+
// a column shared with a differently typed subtype is left for each subtype's hydrator to convert
|
|
359
|
+
if (meta.props.some(p => p !== prop && p.name === prop.name && p.fieldNames?.[0] === prop.fieldNames[0])) {
|
|
360
|
+
lines.push(`${padding} if (${defined}) {`);
|
|
361
|
+
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])};`);
|
|
362
|
+
lines.push(`${padding} }`);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
353
366
|
if (prop.runtimeType === 'boolean') {
|
|
354
|
-
lines.push(`${padding} if (
|
|
367
|
+
lines.push(`${padding} if (${defined}) {`);
|
|
355
368
|
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : !!${this.propName(prop.fieldNames[0])};`);
|
|
356
369
|
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
357
370
|
lines.push(`${padding} }`);
|
|
358
371
|
}
|
|
359
372
|
else if (prop.runtimeType === 'Date' && !this.#platform.isNumericProperty(prop)) {
|
|
360
|
-
lines.push(`${padding} if (
|
|
373
|
+
lines.push(`${padding} if (${defined}) {`);
|
|
361
374
|
context.set('parseDate', (value) => this.#platform.parseDate(value));
|
|
362
375
|
parseDate('ret' + this.wrap(prop.name), this.propName(prop.fieldNames[0]), padding);
|
|
363
376
|
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
@@ -372,13 +385,13 @@ export class EntityComparator {
|
|
|
372
385
|
}
|
|
373
386
|
return item == null ? item : this.getResultMapper(prop.targetMeta)(item);
|
|
374
387
|
});
|
|
375
|
-
lines.push(`${padding} if (
|
|
388
|
+
lines.push(`${padding} if (${defined}) {`);
|
|
376
389
|
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : mapEmbeddedResult_${idx}(${this.propName(prop.fieldNames[0])});`);
|
|
377
390
|
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
378
391
|
lines.push(`${padding} }`);
|
|
379
392
|
}
|
|
380
393
|
else if (prop.kind !== ReferenceKind.EMBEDDED) {
|
|
381
|
-
lines.push(`${padding} if (
|
|
394
|
+
lines.push(`${padding} if (${defined}) {`);
|
|
382
395
|
lines.push(`${padding} ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])};`);
|
|
383
396
|
lines.push(`${padding} ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
|
|
384
397
|
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.2-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.2-dev.30';
|
|
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}`;
|