@mikro-orm/core 7.0.0-dev.230 → 7.0.0-dev.231

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.
@@ -578,16 +578,18 @@ export class EntityLoader {
578
578
  }
579
579
  return ret;
580
580
  }, []);
581
- if (ret.length === 0) {
582
- return undefined;
583
- }
584
581
  // we need to automatically select the FKs too, e.g. for 1:m relations to be able to wire them with the items
585
582
  if (prop.kind === ReferenceKind.ONE_TO_MANY || prop.kind === ReferenceKind.MANY_TO_MANY) {
586
583
  const owner = prop.targetMeta.properties[prop.mappedBy];
587
- if (owner && !ret.includes(owner.name)) {
584
+ // when the owning FK is lazy, we need to explicitly select it even without user-provided fields,
585
+ // otherwise the driver will exclude it and we won't be able to map children to their parent collections
586
+ if (owner && !ret.includes(owner.name) && (ret.length > 0 || owner.lazy)) {
588
587
  ret.push(owner.name);
589
588
  }
590
589
  }
590
+ if (ret.length === 0) {
591
+ return undefined;
592
+ }
591
593
  return ret;
592
594
  }
593
595
  getChildReferences(entities, prop, options, ref) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.230",
4
+ "version": "7.0.0-dev.231",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
package/utils/Utils.js CHANGED
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
123
123
  }
124
124
  export class Utils {
125
125
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.0-dev.230';
126
+ static #ORM_VERSION = '7.0.0-dev.231';
127
127
  /**
128
128
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
129
  */