@mikro-orm/core 6.3.3-dev.1 → 6.3.3-dev.10

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.
@@ -58,6 +58,7 @@ export declare class EntityLoader {
58
58
  private buildFields;
59
59
  private getChildReferences;
60
60
  private filterCollections;
61
+ private isPropertyLoaded;
61
62
  private filterReferences;
62
63
  private filterByReferences;
63
64
  private lookupAllRelationships;
@@ -493,6 +493,21 @@ class EntityLoader {
493
493
  }
494
494
  return entities.filter(e => Utils_1.Utils.isCollection(e[field]) && !e[field].isInitialized(!ref));
495
495
  }
496
+ isPropertyLoaded(entity, field) {
497
+ if (!entity) {
498
+ return true;
499
+ }
500
+ const wrapped = (0, wrap_1.helper)(entity);
501
+ if (!field.includes('.')) {
502
+ return wrapped.__loadedProperties.has(field);
503
+ }
504
+ const [f, ...r] = field.split('.');
505
+ if (wrapped.__loadedProperties.has(f) && wrapped.__meta.properties[f]?.targetMeta) {
506
+ return this.isPropertyLoaded(entity[f], r.join('.'));
507
+ }
508
+ /* istanbul ignore next */
509
+ return false;
510
+ }
496
511
  filterReferences(entities, field, options, ref) {
497
512
  if (ref) {
498
513
  return [];
@@ -504,11 +519,12 @@ class EntityLoader {
504
519
  if (options.fields) {
505
520
  return children
506
521
  .filter(e => {
507
- const wrapped = (0, wrap_1.helper)(e[field]);
522
+ const target = e[field];
523
+ const wrapped = (0, wrap_1.helper)(target);
508
524
  const childFields = options.fields
509
525
  .filter(f => f.startsWith(`${field}.`))
510
526
  .map(f => f.substring(field.length + 1));
511
- return !wrapped.__initialized || !childFields.every(field => wrapped.__loadedProperties.has(field));
527
+ return !wrapped.__initialized || !childFields.every(cf => this.isPropertyLoaded(target, cf));
512
528
  })
513
529
  .map(e => Reference_1.Reference.unwrapReference(e[field]));
514
530
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.3-dev.1",
3
+ "version": "6.3.3-dev.10",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.3-dev.1",
67
+ "mikro-orm": "6.3.3-dev.10",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }