@mikro-orm/knex 5.8.1-dev.7 → 5.8.2-dev.0

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.
@@ -601,7 +601,10 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
601
601
  const pk = core_1.Utils.getCompositeKeyHash(item, meta);
602
602
  if (map[pk]) {
603
603
  joinedProps.forEach(hint => {
604
- if (Array.isArray(map[pk][hint.field]) && Array.isArray(item[hint.field])) {
604
+ // Sometimes we might join a M:N relation with additional filter on the target entity, and as a result, we get
605
+ // the first result with `null` for all target values, which is mapped as empty array. When we see that happen,
606
+ // we need to merge the results of the next item.
607
+ if (Array.isArray(map[pk][hint.field]) && Array.isArray(item[hint.field]) && map[pk][hint.field].length === 0) {
605
608
  item[hint.field].forEach((el) => map[pk][hint.field].push(el));
606
609
  }
607
610
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "5.8.1-dev.7",
3
+ "version": "5.8.2-dev.0",
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,12 +63,12 @@
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": "~5.8.1-dev.7",
70
- "@mikro-orm/entity-generator": "~5.8.1-dev.7",
71
- "@mikro-orm/migrations": "~5.8.1-dev.7",
69
+ "@mikro-orm/core": "~5.8.2-dev.0",
70
+ "@mikro-orm/entity-generator": "~5.8.2-dev.0",
71
+ "@mikro-orm/migrations": "~5.8.2-dev.0",
72
72
  "better-sqlite3": "*",
73
73
  "mssql": "*",
74
74
  "mysql": "*",