@mikro-orm/core 6.4.17-dev.74 → 6.4.17-dev.75

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 CHANGED
@@ -282,7 +282,7 @@ class EntityManager {
282
282
  for (const hint of options.populate) {
283
283
  const field = hint.field.split(':')[0];
284
284
  const prop = meta.properties[field];
285
- const strategy = (0, utils_2.getLoadingStrategy)(prop.strategy || options.strategy || hint.strategy || this.config.get('loadStrategy'), prop.kind);
285
+ const strategy = (0, utils_2.getLoadingStrategy)(prop.strategy || hint.strategy || options.strategy || this.config.get('loadStrategy'), prop.kind);
286
286
  const joined = strategy === enums_1.LoadStrategy.JOINED && prop.kind !== enums_1.ReferenceKind.SCALAR;
287
287
  if (!joined && !hint.filter) {
288
288
  continue;
@@ -320,10 +320,19 @@ class EntityManager {
320
320
  const cond = await this.applyFilters(prop.type, {}, options.filters ?? {}, 'read', options);
321
321
  if (!utils_1.Utils.isEmpty(cond)) {
322
322
  const populated = options.populate.filter(({ field }) => field.split(':')[0] === prop.name);
323
+ let found = false;
323
324
  if (populated.length > 0) {
324
- populated.forEach(hint => hint.filter = true);
325
+ for (const hint of populated) {
326
+ if (!hint.all) {
327
+ hint.filter = true;
328
+ found = true;
329
+ }
330
+ else if (hint.field === `${prop.name}:ref`) {
331
+ found = true;
332
+ }
333
+ }
325
334
  }
326
- else {
335
+ if (!found) {
327
336
  ret.push({ field: `${prop.name}:ref`, strategy: enums_1.LoadStrategy.JOINED, filter: true });
328
337
  }
329
338
  }
@@ -41,7 +41,7 @@ class EntityLoader {
41
41
  options.refresh ??= false;
42
42
  options.convertCustomTypes ??= true;
43
43
  if (references.length > 0) {
44
- await this.populateScalar(meta, references, options);
44
+ await this.populateScalar(meta, references, { ...options, populateWhere: undefined });
45
45
  }
46
46
  populate = this.normalizePopulate(entityName, populate, options.strategy, options.lookup);
47
47
  const invalid = populate.find(({ field }) => !this.em.canPopulate(entityName, field));
package/entity/utils.js CHANGED
@@ -38,7 +38,6 @@ function expandDotPaths(meta, populate, normalized = false) {
38
38
  p.field = f;
39
39
  p.children ??= [];
40
40
  const prop = meta.properties[p.field];
41
- p.strategy ??= prop.strategy;
42
41
  if (parts[0] === enums_1.PopulatePath.ALL) {
43
42
  prop.targetMeta.props
44
43
  .filter(prop => prop.lazy || prop.kind !== enums_1.ReferenceKind.SCALAR)
package/enums.d.ts CHANGED
@@ -85,6 +85,7 @@ export declare enum QueryFlag {
85
85
  INCLUDE_LAZY_FORMULAS = "INCLUDE_LAZY_FORMULAS",
86
86
  AUTO_JOIN_ONE_TO_ONE_OWNER = "AUTO_JOIN_ONE_TO_ONE_OWNER",
87
87
  INFER_POPULATE = "INFER_POPULATE",
88
+ DISABLE_NESTED_INNER_JOIN = "DISABLE_NESTED_INNER_JOIN",
88
89
  IDENTITY_INSERT = "IDENTITY_INSERT"
89
90
  }
90
91
  export declare const SCALAR_TYPES: string[];
@@ -109,7 +110,6 @@ export declare enum Cascade {
109
110
  export declare enum LoadStrategy {
110
111
  SELECT_IN = "select-in",
111
112
  JOINED = "joined",
112
- INNER_JOINED = "inner-joined",
113
113
  BALANCED = "balanced"
114
114
  }
115
115
  export declare enum DataloaderType {
package/enums.js CHANGED
@@ -98,6 +98,7 @@ var QueryFlag;
98
98
  QueryFlag["INCLUDE_LAZY_FORMULAS"] = "INCLUDE_LAZY_FORMULAS";
99
99
  QueryFlag["AUTO_JOIN_ONE_TO_ONE_OWNER"] = "AUTO_JOIN_ONE_TO_ONE_OWNER";
100
100
  QueryFlag["INFER_POPULATE"] = "INFER_POPULATE";
101
+ QueryFlag["DISABLE_NESTED_INNER_JOIN"] = "DISABLE_NESTED_INNER_JOIN";
101
102
  QueryFlag["IDENTITY_INSERT"] = "IDENTITY_INSERT";
102
103
  })(QueryFlag || (exports.QueryFlag = QueryFlag = {}));
103
104
  exports.SCALAR_TYPES = ['string', 'number', 'boolean', 'bigint', 'Date', 'Buffer', 'RegExp'];
@@ -125,7 +126,6 @@ var LoadStrategy;
125
126
  (function (LoadStrategy) {
126
127
  LoadStrategy["SELECT_IN"] = "select-in";
127
128
  LoadStrategy["JOINED"] = "joined";
128
- LoadStrategy["INNER_JOINED"] = "inner-joined";
129
129
  LoadStrategy["BALANCED"] = "balanced";
130
130
  })(LoadStrategy || (exports.LoadStrategy = LoadStrategy = {}));
131
131
  var DataloaderType;
@@ -825,9 +825,16 @@ class MetadataDiscovery {
825
825
  }
826
826
  return prop.embedded ? isParentObject(meta.properties[prop.embedded[0]]) : false;
827
827
  };
828
+ const isParentArray = (prop) => {
829
+ if (prop.array) {
830
+ return true;
831
+ }
832
+ return prop.embedded ? isParentArray(meta.properties[prop.embedded[0]]) : false;
833
+ };
828
834
  const rootProperty = getRootProperty(embeddedProp);
829
835
  const parentProperty = meta.properties[embeddedProp.embedded?.[0] ?? ''];
830
836
  const object = isParentObject(embeddedProp);
837
+ const array = isParentArray(embeddedProp);
831
838
  this.initFieldName(embeddedProp, rootProperty !== embeddedProp && object);
832
839
  // the prefix of the parent cannot be a boolean; it already passed here
833
840
  const prefix = this.getPrefix(embeddedProp, parentProperty);
@@ -840,7 +847,8 @@ class MetadataDiscovery {
840
847
  meta.propertyOrder.set(name, (order += 0.01));
841
848
  embeddedProp.embeddedProps[prop.name] = meta.properties[name];
842
849
  meta.properties[name].persist ??= embeddedProp.persist;
843
- if (embeddedProp.nullable) {
850
+ const refInArray = array && [enums_1.ReferenceKind.MANY_TO_ONE, enums_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind) && prop.owner;
851
+ if (embeddedProp.nullable || refInArray) {
844
852
  meta.properties[name].nullable = true;
845
853
  }
846
854
  if (meta.properties[name].fieldNames) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.17-dev.74",
3
+ "version": "6.4.17-dev.75",
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.1",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.17-dev.74",
67
+ "mikro-orm": "6.4.17-dev.75",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }