@mikro-orm/sql 7.0.12-dev.1 → 7.0.12-dev.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.12-dev.1",
3
+ "version": "7.0.12-dev.3",
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
  "keywords": [
6
6
  "data-mapper",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.0.11"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.12-dev.1"
56
+ "@mikro-orm/core": "7.0.12-dev.3"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -51,7 +51,15 @@ export class CriteriaNode {
51
51
  }
52
52
  shouldRename(payload) {
53
53
  const type = this.prop ? this.prop.kind : null;
54
- const composite = this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false;
54
+ // Polymorphic relations have a composite column set (discriminator + FK), but we only
55
+ // need tuple-renaming when the payload is itself a tuple (entity ref expanded by
56
+ // `convertCompositeEntityRefs`) or an array-valued operator like `$in`. Scalar payloads
57
+ // such as `null` or `{ $ne: null }` keep single-column semantics against `fieldNames[0]`.
58
+ const polymorphicComposite = !!this.prop?.polymorphic &&
59
+ (this.prop.fieldNames?.length ?? 0) > 1 &&
60
+ (Array.isArray(payload) ||
61
+ (Utils.isPlainObject(payload) && Object.values(payload).some(v => Array.isArray(v))));
62
+ const composite = polymorphicComposite || (this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false);
55
63
  const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
56
64
  const scalar = payload === null ||
57
65
  Utils.isPrimaryKey(payload) ||
@@ -82,7 +90,8 @@ export class CriteriaNode {
82
90
  [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) &&
83
91
  this.prop.owner) {
84
92
  const alias = qb.getAliasForJoinPath(this.parent.getPath()) ?? ownerAlias ?? qb.alias;
85
- return Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${alias}.${col}`));
93
+ const columns = this.prop.polymorphic ? this.prop.fieldNames : this.prop.joinColumns;
94
+ return Utils.getPrimaryKeyHash(columns.map(col => `${alias}.${col}`));
86
95
  }
87
96
  const alias = joinAlias ?? ownerAlias ?? qb.alias;
88
97
  if (this.prop.kind === ReferenceKind.MANY_TO_MANY) {