@mikro-orm/knex 6.0.0-dev.264 → 6.0.0-dev.265

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.
@@ -231,25 +231,26 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
231
231
  relationPojo[prop.name] = root[alias];
232
232
  }
233
233
  });
234
- meta2.props
235
- .filter(prop => this.platform.shouldHaveColumn(prop, hint.children || []))
236
- .forEach(prop => {
237
- if (prop.fieldNames.length > 1) { // composite keys
238
- const fk = prop.fieldNames.map(name => root[`${relationAlias}__${name}`]);
239
- prop.fieldNames.map(name => delete root[`${relationAlias}__${name}`]);
240
- relationPojo[prop.name] = core_1.Utils.mapFlatCompositePrimaryKey(fk, prop);
234
+ const props = meta2.props.filter(prop => this.platform.shouldHaveColumn(prop, hint.children || []));
235
+ for (const prop1 of props) {
236
+ if (prop1.fieldNames.length > 1) { // composite keys
237
+ const fk = prop1.fieldNames.map(name => root[`${relationAlias}__${name}`]);
238
+ relationPojo[prop1.name] = core_1.Utils.mapFlatCompositePrimaryKey(fk, prop1);
241
239
  }
242
- else if (prop.runtimeType === 'Date') {
243
- const alias = `${relationAlias}__${prop.fieldNames[0]}`;
244
- relationPojo[prop.name] = (typeof root[alias] === 'string' ? new Date(root[alias]) : root[alias]);
245
- delete root[alias];
240
+ else if (prop1.runtimeType === 'Date') {
241
+ const alias = `${relationAlias}__${prop1.fieldNames[0]}`;
242
+ relationPojo[prop1.name] = (typeof root[alias] === 'string' ? new Date(root[alias]) : root[alias]);
246
243
  }
247
244
  else {
248
- const alias = `${relationAlias}__${prop.fieldNames[0]}`;
249
- relationPojo[prop.name] = root[alias];
250
- delete root[alias];
245
+ const alias = `${relationAlias}__${prop1.fieldNames[0]}`;
246
+ relationPojo[prop1.name] = root[alias];
251
247
  }
252
- });
248
+ }
249
+ // properties can be mapped to multiple places, e.g. when sharing a column in multiple FKs,
250
+ // so we need to delete them after everything is mapped from given level
251
+ for (const prop1 of props) {
252
+ prop1.fieldNames.map(name => delete root[`${relationAlias}__${name}`]);
253
+ }
253
254
  if ([core_1.ReferenceKind.MANY_TO_MANY, core_1.ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {
254
255
  result[prop.name] ??= [];
255
256
  result[prop.name].push(relationPojo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.264",
3
+ "version": "6.0.0-dev.265",
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",
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^5.9.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.0-dev.264"
69
+ "@mikro-orm/core": "6.0.0-dev.265"
70
70
  }
71
71
  }