@mikro-orm/core 7.2.1-dev.13 → 7.2.1-dev.15

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
@@ -489,7 +489,8 @@ export class EntityManager {
489
489
  return userFilter;
490
490
  }
491
491
  const ret = {};
492
- for (const hint of options.populate) {
492
+ const populate = options.populate;
493
+ for (const hint of populate) {
493
494
  const field = hint.field.split(':')[0];
494
495
  const prop = meta.properties[field];
495
496
  const strategy = getLoadingStrategy(prop.strategy || hint.strategy || options.strategy || this.config.get('loadStrategy'), prop.kind);
@@ -533,6 +534,16 @@ export class EntityManager {
533
534
  if (userFilter) {
534
535
  Utils.merge(ret, userFilter);
535
536
  }
537
+ for (const hint of populate) {
538
+ const [field, ref] = hint.field.split(':');
539
+ // Filtered M:N refs need the target join and its PKs (unless a plain hint for the field already provides them).
540
+ if (ref &&
541
+ meta.properties[field].kind === ReferenceKind.MANY_TO_MANY &&
542
+ ret[field] &&
543
+ !populate.some(other => other.field === field)) {
544
+ hint.filter = true;
545
+ }
546
+ }
536
547
  return Utils.hasObjectKeys(ret) ? ret : undefined;
537
548
  }
538
549
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.1-dev.13",
3
+ "version": "7.2.1-dev.15",
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
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.2.1-dev.13';
156
+ static #ORM_VERSION = '7.2.1-dev.15';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;