@mikro-orm/knex 6.0.0-dev.93 → 6.0.0-dev.95

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.
@@ -662,8 +662,11 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
662
662
  const pk = core_1.Utils.getCompositeKeyHash(item, meta);
663
663
  if (map[pk]) {
664
664
  joinedProps.forEach(hint => {
665
- if (Array.isArray(map[pk][hint.field]) && Array.isArray(item[hint.field])) {
666
- map[pk][hint.field].push(...item[hint.field]);
665
+ // Sometimes we might join a M:N relation with additional filter on the target entity, and as a result, we get
666
+ // the first result with `null` for all target values, which is mapped as empty array. When we see that happen,
667
+ // we need to merge the results of the next item.
668
+ if (Array.isArray(map[pk][hint.field]) && Array.isArray(item[hint.field]) && map[pk][hint.field].length === 0) {
669
+ item[hint.field].forEach((el) => map[pk][hint.field].push(el));
667
670
  }
668
671
  });
669
672
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.93",
3
+ "version": "6.0.0-dev.95",
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",
@@ -63,9 +63,9 @@
63
63
  "sqlstring": "2.3.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@mikro-orm/core": "^5.8.0"
66
+ "@mikro-orm/core": "^5.8.1"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "~6.0.0-dev.93"
69
+ "@mikro-orm/core": "~6.0.0-dev.95"
70
70
  }
71
71
  }