@mikro-orm/core 6.4.16-dev.4 → 6.4.16-dev.6

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.
@@ -231,7 +231,7 @@ class EntityLoader {
231
231
  let where = this.mergePrimaryCondition(ids, fk, options, meta, this.metadata, this.driver.getPlatform());
232
232
  const fields = this.buildFields(options.fields, prop, ref);
233
233
  /* eslint-disable prefer-const */
234
- let { refresh, filters, convertCustomTypes, lockMode, strategy, populateWhere, connectionType, logging, } = options;
234
+ let { refresh, filters, convertCustomTypes, lockMode, strategy, populateWhere = 'infer', connectionType, logging, } = options;
235
235
  /* eslint-enable prefer-const */
236
236
  if (typeof populateWhere === 'object') {
237
237
  populateWhere = await this.extractChildCondition({ where: populateWhere }, prop);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.16-dev.4",
3
+ "version": "6.4.16-dev.6",
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.3.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.16-dev.4",
67
+ "mikro-orm": "6.4.16-dev.6",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -76,18 +76,21 @@ class SerializationContext {
76
76
  }
77
77
  }
78
78
  isMarkedAsPopulated(entityName, prop) {
79
- let populate = this.populate;
79
+ let populate = this.populate ?? [];
80
80
  for (const segment of this.path) {
81
- if (!populate) {
82
- return false;
83
- }
84
- const exists = populate.find(p => p.field === segment[1]);
85
- if (exists) {
86
- // we need to check for cycles here too, as we could fall into endless loops for bidirectional relations
87
- if (exists.all) {
88
- return !this.path.find(([cls, item]) => entityName === cls && prop === item);
81
+ const hints = populate.filter(p => p.field === segment[1]);
82
+ if (hints.length > 0) {
83
+ const childHints = [];
84
+ for (const hint of hints) {
85
+ // we need to check for cycles here too, as we could fall into endless loops for bidirectional relations
86
+ if (hint.all) {
87
+ return !this.path.find(([cls, item]) => entityName === cls && prop === item);
88
+ }
89
+ if (hint.children) {
90
+ childHints.push(...hint.children);
91
+ }
89
92
  }
90
- populate = exists.children;
93
+ populate = childHints;
91
94
  }
92
95
  }
93
96
  return !!populate?.some(p => p.field === prop);