@mikro-orm/knex 6.2.8-dev.0 → 6.2.8-dev.2

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.
@@ -240,6 +240,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
240
240
  const targetProps = ref
241
241
  ? meta2.getPrimaryProps()
242
242
  : meta2.props.filter(prop => this.platform.shouldHaveColumn(prop, hint.children || []));
243
+ const tz = this.platform.getTimezone();
243
244
  for (const prop of targetProps) {
244
245
  if (prop.fieldNames.length > 1) { // composite keys
245
246
  const fk = prop.fieldNames.map(name => root[`${relationAlias}__${name}`]);
@@ -248,8 +249,16 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
248
249
  }
249
250
  else if (prop.runtimeType === 'Date') {
250
251
  const alias = `${relationAlias}__${prop.fieldNames[0]}`;
251
- const type = typeof root[alias];
252
- relationPojo[prop.name] = (['string', 'number'].includes(type) ? this.platform.parseDate(root[alias]) : root[alias]);
252
+ const value = root[alias];
253
+ if (tz && tz !== 'local' && typeof value === 'string' && !value.includes('+') && !value.endsWith('Z')) {
254
+ relationPojo[prop.name] = this.platform.parseDate(value + tz);
255
+ }
256
+ else if (['string', 'number'].includes(typeof value)) {
257
+ relationPojo[prop.name] = this.platform.parseDate(value);
258
+ }
259
+ else {
260
+ relationPojo[prop.name] = value;
261
+ }
253
262
  }
254
263
  else {
255
264
  const alias = `${relationAlias}__${prop.fieldNames[0]}`;
@@ -740,19 +749,13 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
740
749
  if (owners.length === 1 && (options.offset != null || options.limit != null)) {
741
750
  qb.limit(options.limit, options.offset);
742
751
  }
743
- // console.log('pivot qb', qb, qb._fields);
744
752
  const res = owners.length ? await this.rethrow(qb.execute('all', { mergeResults: false, mapResults: false })) : [];
745
- // console.log(res);
746
- // const items = res.map((row: Dictionary) => super.mapResult(row, prop.targetMeta));
747
753
  const tmp = {};
748
- // const items = res.map((row: Dictionary) => this.mapResult(row, prop.targetMeta!, populate, qb, tmp));
749
- // const items = res.map((row: Dictionary) => this.mapResult(row, pivotMeta, populate, qb, tmp));
750
754
  const items = res.map((row) => {
751
755
  const root = super.mapResult(row, prop.targetMeta);
752
756
  this.mapJoinedProps(root, prop.targetMeta, populate, qb, root, tmp, pivotMeta.className + '.' + pivotProp1.name);
753
757
  return root;
754
758
  });
755
- // console.log(prop.name, prop.targetMeta!.className, items);
756
759
  qb.clearRawFragmentsCache();
757
760
  const map = {};
758
761
  const pkProps = ownerMeta.getPrimaryProps();
@@ -889,7 +892,6 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
889
892
  const prop = meta.properties[propName];
890
893
  // ignore ref joins of known FKs unless it's a filter hint
891
894
  if (ref && !hint.filter && (prop.kind === core_1.ReferenceKind.MANY_TO_ONE || (prop.kind === core_1.ReferenceKind.ONE_TO_ONE && !prop.owner))) {
892
- // // console.log('wat', hint);
893
895
  return;
894
896
  }
895
897
  const meta2 = this.metadata.find(prop.type);
@@ -923,11 +925,9 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
923
925
  fields.push(...this.getFieldsForJoinedLoad(qb, meta2, childExplicitFields.length === 0 ? undefined : childExplicitFields, childExclude, hint.children, options, tableAlias, path));
924
926
  }
925
927
  else if (hint.filter) {
926
- // fields.push(field);
927
928
  fields.push(...prop.referencedColumnNames.map(col => qb.helper.mapper(`${tableAlias}.${col}`, qb.type, undefined, `${tableAlias}__${col}`)));
928
929
  }
929
930
  });
930
- // // console.log(fields, joinedProps);
931
931
  return fields;
932
932
  }
933
933
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.2.8-dev.0",
3
+ "version": "6.2.8-dev.2",
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": "^6.2.7"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.2.8-dev.0"
69
+ "@mikro-orm/core": "6.2.8-dev.2"
70
70
  }
71
71
  }