@mikro-orm/knex 6.4.7-dev.11 → 6.4.7-dev.13

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.
@@ -930,11 +930,11 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
930
930
  getFieldsForJoinedLoad(qb, meta, explicitFields, exclude, populate = [], options, parentTableAlias, parentJoinPath, count) {
931
931
  const fields = [];
932
932
  const joinedProps = this.joinedProps(meta, populate, options);
933
- const shouldHaveColumn = (prop, populate, fields) => {
933
+ const shouldHaveColumn = (meta, prop, populate, fields) => {
934
934
  if (!this.platform.shouldHaveColumn(prop, populate, exclude)) {
935
935
  return false;
936
936
  }
937
- if (!fields || fields.includes('*') || prop.primary) {
937
+ if (!fields || fields.includes('*') || prop.primary || meta.root.discriminatorColumn === prop.name) {
938
938
  return true;
939
939
  }
940
940
  return fields.some(f => f === prop.name || f.toString().startsWith(prop.name + '.'));
@@ -944,7 +944,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
944
944
  if (parentJoinPath) {
945
945
  // alias all fields in the primary table
946
946
  meta.props
947
- .filter(prop => shouldHaveColumn(prop, populate, explicitFields))
947
+ .filter(prop => shouldHaveColumn(meta, prop, populate, explicitFields))
948
948
  .forEach(prop => fields.push(...this.mapPropToFieldNames(qb, prop, parentTableAlias)));
949
949
  }
950
950
  for (const hint of joinedProps) {
@@ -1281,6 +1281,9 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
1281
1281
  if (!options.fields.includes('*') && !options.fields.includes(`${qb.alias}.*`)) {
1282
1282
  ret.unshift(...meta.primaryKeys.filter(pk => !options.fields.includes(pk)));
1283
1283
  }
1284
+ if (meta.root.discriminatorColumn && !options.fields.includes(`${qb.alias}.${meta.root.discriminatorColumn}`)) {
1285
+ ret.push(meta.root.discriminatorColumn);
1286
+ }
1284
1287
  }
1285
1288
  else if (!core_1.Utils.isEmpty(options.exclude) || lazyProps.some(p => !p.formula && (p.kind !== '1:1' || p.owner))) {
1286
1289
  const props = meta.props.filter(prop => this.platform.shouldHaveColumn(prop, populate, options.exclude, false));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.4.7-dev.11",
3
+ "version": "6.4.7-dev.13",
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,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.4.6"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.4.7-dev.11",
69
+ "@mikro-orm/core": "6.4.7-dev.13",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"