@mikro-orm/core 7.2.9-dev.1 → 7.2.9-dev.3
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 +12 -2
- package/entity/EntityLoader.js +10 -1
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -1318,7 +1318,7 @@ export class EntityManager {
|
|
|
1318
1318
|
// an empty condition identifies no row, it must not turn into a reload condition matching every row
|
|
1319
1319
|
const getRowUniqueFields = (where) => Utils.isPlainObject(where) && !Utils.hasObjectKeys(where) ? uniqueFields : getUniqueFields(where);
|
|
1320
1320
|
const platform = this.getPlatform();
|
|
1321
|
-
const returning = getOnConflictReturningFields(meta,
|
|
1321
|
+
const returning = getOnConflictReturningFields(meta, allData[0], uniqueFields, options, platform);
|
|
1322
1322
|
if (options.onConflictWhere && res.rows?.length !== allData.length) {
|
|
1323
1323
|
returning.push(...meta.comparableProps.filter(p => !p.lazy && !p.embeddable).map(p => p.name));
|
|
1324
1324
|
}
|
|
@@ -2399,7 +2399,17 @@ export class EntityManager {
|
|
|
2399
2399
|
}
|
|
2400
2400
|
let autoRefresh;
|
|
2401
2401
|
if (options.fields) {
|
|
2402
|
-
|
|
2402
|
+
// inline embeddables track only their leaf properties as loaded, not the parent
|
|
2403
|
+
const isLoaded = (prop) => helper(entity).__loadedProperties.has(prop.name) ||
|
|
2404
|
+
(prop.kind === ReferenceKind.EMBEDDED && !prop.object && Object.values(prop.embeddedProps).every(isLoaded));
|
|
2405
|
+
autoRefresh = options.fields.some(field => {
|
|
2406
|
+
const [first, ...rest] = field.split('.');
|
|
2407
|
+
let prop = meta.properties[first];
|
|
2408
|
+
for (const part of rest) {
|
|
2409
|
+
prop = prop?.kind === ReferenceKind.EMBEDDED && !prop.object ? prop.embeddedProps[part] : undefined;
|
|
2410
|
+
}
|
|
2411
|
+
return !prop || !isLoaded(prop);
|
|
2412
|
+
});
|
|
2403
2413
|
}
|
|
2404
2414
|
else {
|
|
2405
2415
|
autoRefresh = meta.comparableProps.some(prop => {
|
package/entity/EntityLoader.js
CHANGED
|
@@ -501,6 +501,11 @@ export class EntityLoader {
|
|
|
501
501
|
for (const entity of entities) {
|
|
502
502
|
const ref = entity[prop.name];
|
|
503
503
|
if (ref == null) {
|
|
504
|
+
// an inverse 1:1 with no matching row is resolved as empty, mark it so it is not queried again
|
|
505
|
+
if (isInverseOneToOne && !partial && childrenMap.has(getKey(entity))) {
|
|
506
|
+
entity[prop.name] = nullVal;
|
|
507
|
+
helper(entity).__loadedProperties.add(prop.name);
|
|
508
|
+
}
|
|
504
509
|
continue;
|
|
505
510
|
}
|
|
506
511
|
const refKey = getKey(ref);
|
|
@@ -883,7 +888,11 @@ export class EntityLoader {
|
|
|
883
888
|
if (value === null) {
|
|
884
889
|
return false;
|
|
885
890
|
}
|
|
886
|
-
|
|
891
|
+
// with `forceUndefined`, an empty relation that was already loaded is `undefined` instead of `null`
|
|
892
|
+
if (value === undefined) {
|
|
893
|
+
return !helper(e).__loadedProperties.has(prop.name);
|
|
894
|
+
}
|
|
895
|
+
if (!Utils.isEntity(value, true)) {
|
|
887
896
|
return true;
|
|
888
897
|
}
|
|
889
898
|
const target = Reference.unwrapReference(value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.2.9-dev.
|
|
3
|
+
"version": "7.2.9-dev.3",
|
|
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",
|
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.9-dev.
|
|
156
|
+
static #ORM_VERSION = '7.2.9-dev.3';
|
|
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}`;
|