@mikro-orm/sql 7.0.12-dev.1 → 7.0.12-dev.10
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 +2 -2
- package/query/CriteriaNode.d.ts +1 -1
- package/query/CriteriaNode.js +13 -4
- package/query/ObjectCriteriaNode.js +1 -1
- package/typings.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.0.12-dev.
|
|
3
|
+
"version": "7.0.12-dev.10",
|
|
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.
|
|
56
|
+
"@mikro-orm/core": "7.0.12-dev.10"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/query/CriteriaNode.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare class CriteriaNode<T extends object> implements ICriteriaNode<T>
|
|
|
21
21
|
shouldInline(payload: any): boolean;
|
|
22
22
|
willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
|
|
23
23
|
shouldRename(payload: any): boolean;
|
|
24
|
-
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
|
|
24
|
+
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string, options?: ICriteriaNodeProcessOptions): string;
|
|
25
25
|
getPath(opts?: {
|
|
26
26
|
addIndex?: boolean;
|
|
27
27
|
parentPath?: string;
|
package/query/CriteriaNode.js
CHANGED
|
@@ -51,7 +51,15 @@ export class CriteriaNode {
|
|
|
51
51
|
}
|
|
52
52
|
shouldRename(payload) {
|
|
53
53
|
const type = this.prop ? this.prop.kind : null;
|
|
54
|
-
|
|
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) ||
|
|
@@ -75,14 +83,15 @@ export class CriteriaNode {
|
|
|
75
83
|
return false;
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
renameFieldToPK(qb, ownerAlias) {
|
|
79
|
-
const joinAlias = qb.getAliasForJoinPath(this.getPath(), { matchPopulateJoins: true });
|
|
86
|
+
renameFieldToPK(qb, ownerAlias, options) {
|
|
87
|
+
const joinAlias = qb.getAliasForJoinPath(this.getPath(), { ...options, matchPopulateJoins: true });
|
|
80
88
|
if (!joinAlias &&
|
|
81
89
|
this.parent &&
|
|
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
|
-
|
|
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) {
|
|
@@ -105,7 +105,7 @@ export class ObjectCriteriaNode extends CriteriaNode {
|
|
|
105
105
|
this.inlineChildPayload(o, payload, field, a, childAlias);
|
|
106
106
|
}
|
|
107
107
|
else if (childNode.shouldRename(payload)) {
|
|
108
|
-
this.inlineCondition(childNode.renameFieldToPK(qb, alias), o, payload);
|
|
108
|
+
this.inlineCondition(childNode.renameFieldToPK(qb, alias, options), o, payload);
|
|
109
109
|
}
|
|
110
110
|
else if (isRawField) {
|
|
111
111
|
const rawField = RawQueryFragment.getKnownFragment(field);
|
package/typings.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export interface ICriteriaNode<T extends object> {
|
|
|
233
233
|
shouldInline(payload: any): boolean;
|
|
234
234
|
willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
|
|
235
235
|
shouldRename(payload: any): boolean;
|
|
236
|
-
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
|
|
236
|
+
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string, options?: ICriteriaNodeProcessOptions): string;
|
|
237
237
|
getPath(opts?: {
|
|
238
238
|
addIndex?: boolean;
|
|
239
239
|
}): string;
|