@mikro-orm/core 7.0.17-dev.3 → 7.0.17-dev.4
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/EntityLoader.js +32 -5
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/entity/EntityLoader.js
CHANGED
|
@@ -334,10 +334,10 @@ export class EntityLoader {
|
|
|
334
334
|
fk = ownerProp.name;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
if (prop.kind === ReferenceKind.ONE_TO_ONE && !prop.owner && !ref) {
|
|
337
|
+
if (prop.kind === ReferenceKind.ONE_TO_ONE && !prop.owner && (!ref || (!prop.mapToPk && !populate.filter))) {
|
|
338
338
|
children.length = 0;
|
|
339
339
|
fk = meta.properties[prop.mappedBy].name;
|
|
340
|
-
children.push(...this.filterByReferences(entities, prop
|
|
340
|
+
children.push(...this.filterByReferences(entities, prop, options, ref));
|
|
341
341
|
}
|
|
342
342
|
if (children.length === 0) {
|
|
343
343
|
return { items: [], partial };
|
|
@@ -753,12 +753,39 @@ export class EntityLoader {
|
|
|
753
753
|
.filter(e => !e[field].__helper.__initialized)
|
|
754
754
|
.map(e => Reference.unwrapReference(e[field]));
|
|
755
755
|
}
|
|
756
|
-
filterByReferences(entities,
|
|
756
|
+
filterByReferences(entities, prop, options, ref) {
|
|
757
757
|
/* v8 ignore next */
|
|
758
|
-
if (refresh) {
|
|
758
|
+
if (options.refresh) {
|
|
759
759
|
return entities;
|
|
760
760
|
}
|
|
761
|
-
|
|
761
|
+
const field = prop.name;
|
|
762
|
+
return entities.filter(e => {
|
|
763
|
+
const value = e[field];
|
|
764
|
+
if (value === null) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
if (value === undefined || !Utils.isEntity(value, true)) {
|
|
768
|
+
return true;
|
|
769
|
+
}
|
|
770
|
+
const target = Reference.unwrapReference(value);
|
|
771
|
+
const wrapped = helper(target);
|
|
772
|
+
if (!wrapped.__initialized) {
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
if (ref) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
if (options.fields) {
|
|
779
|
+
const childFields = options.fields
|
|
780
|
+
.filter(f => f.startsWith(`${prop.name}.`))
|
|
781
|
+
.map(f => f.substring(prop.name.length + 1));
|
|
782
|
+
return childFields.length > 0 && !childFields.every(f => this.isPropertyLoaded(target, f));
|
|
783
|
+
}
|
|
784
|
+
return prop.targetMeta.comparableProps.some(targetProp => {
|
|
785
|
+
const inlineEmbedded = targetProp.kind === ReferenceKind.EMBEDDED && !targetProp.object;
|
|
786
|
+
return !inlineEmbedded && !targetProp.lazy && !wrapped.__loadedProperties.has(targetProp.name);
|
|
787
|
+
});
|
|
788
|
+
});
|
|
762
789
|
}
|
|
763
790
|
lookupAllRelationships(entityName) {
|
|
764
791
|
const ret = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.17-dev.
|
|
3
|
+
"version": "7.0.17-dev.4",
|
|
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
|
@@ -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.0.17-dev.
|
|
144
|
+
static #ORM_VERSION = '7.0.17-dev.4';
|
|
145
145
|
/**
|
|
146
146
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
147
147
|
*/
|