@mikro-orm/sql 7.0.0-dev.120 → 7.0.0-dev.122
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/plugin/transformer.d.ts +1 -1
- package/query/CriteriaNode.d.ts +4 -1
- package/query/CriteriaNode.js +3 -3
- package/query/ObjectCriteriaNode.js +2 -2
- package/query/QueryBuilder.js +3 -1
- package/query/QueryBuilderHelper.js +3 -0
- package/query/ScalarCriteriaNode.js +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/typings.d.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.122",
|
|
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
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"@mikro-orm/core": "^6.6.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
59
|
+
"@mikro-orm/core": "7.0.0-dev.122"
|
|
60
60
|
}
|
|
61
61
|
}
|
package/plugin/transformer.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class MikroTransformer extends OperationNodeTransformer {
|
|
|
23
23
|
* Global map of all entities involved in the query.
|
|
24
24
|
* Populated during AST transformation and used for result transformation.
|
|
25
25
|
*/
|
|
26
|
-
protected readonly entityMap: Map<string, EntityMetadata<any
|
|
26
|
+
protected readonly entityMap: Map<string, EntityMetadata<any, import("@mikro-orm/core").EntityCtor<any>>>;
|
|
27
27
|
constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
|
|
28
28
|
reset(): void;
|
|
29
29
|
getOutputEntityMap(): Map<string, EntityMetadata>;
|
package/query/CriteriaNode.d.ts
CHANGED
|
@@ -21,7 +21,10 @@ export declare class CriteriaNode<T extends object> implements ICriteriaNode<T>
|
|
|
21
21
|
willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
|
|
22
22
|
shouldRename(payload: any): boolean;
|
|
23
23
|
renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string): string;
|
|
24
|
-
getPath(
|
|
24
|
+
getPath(opts?: {
|
|
25
|
+
addIndex?: boolean;
|
|
26
|
+
parentPath?: string;
|
|
27
|
+
}): string;
|
|
25
28
|
private isPivotJoin;
|
|
26
29
|
getPivotPath(path: string): string;
|
|
27
30
|
aliased(field: string, alias?: string): string;
|
package/query/CriteriaNode.js
CHANGED
|
@@ -76,11 +76,11 @@ export class CriteriaNode {
|
|
|
76
76
|
}
|
|
77
77
|
return Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
|
|
78
78
|
}
|
|
79
|
-
getPath(
|
|
79
|
+
getPath(opts) {
|
|
80
80
|
// use index on parent only if we are processing to-many relation
|
|
81
81
|
const addParentIndex = this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
|
|
82
|
-
const parentPath = this.parent?.getPath(addParentIndex) ?? Utils.className(this.entityName);
|
|
83
|
-
const index = addIndex && this.index != null ? `[${this.index}]` : '';
|
|
82
|
+
const parentPath = opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName);
|
|
83
|
+
const index = opts?.addIndex && this.index != null ? `[${this.index}]` : '';
|
|
84
84
|
// ignore group operators to allow easier mapping (e.g. for orderBy)
|
|
85
85
|
const key = this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key) ? '.' + this.key : '';
|
|
86
86
|
const ret = parentPath + index + key;
|
|
@@ -7,7 +7,7 @@ import { JoinType, QueryType } from './enums.js';
|
|
|
7
7
|
export class ObjectCriteriaNode extends CriteriaNode {
|
|
8
8
|
process(qb, options) {
|
|
9
9
|
const matchPopulateJoins = options?.matchPopulateJoins || (this.prop && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind));
|
|
10
|
-
const nestedAlias = qb.getAliasForJoinPath(this.getPath(), { ...options, matchPopulateJoins });
|
|
10
|
+
const nestedAlias = qb.getAliasForJoinPath(this.getPath(options), { ...options, matchPopulateJoins });
|
|
11
11
|
const ownerAlias = options?.alias || qb.alias;
|
|
12
12
|
const keys = Utils.getObjectQueryKeys(this.payload);
|
|
13
13
|
let alias = options?.alias;
|
|
@@ -117,7 +117,7 @@ export class ObjectCriteriaNode extends CriteriaNode {
|
|
|
117
117
|
}, {});
|
|
118
118
|
}
|
|
119
119
|
willAutoJoin(qb, alias, options) {
|
|
120
|
-
const nestedAlias = qb.getAliasForJoinPath(this.getPath(), options);
|
|
120
|
+
const nestedAlias = qb.getAliasForJoinPath(this.getPath(options), options);
|
|
121
121
|
const ownerAlias = alias || qb.alias;
|
|
122
122
|
const keys = Utils.getObjectQueryKeys(this.payload);
|
|
123
123
|
if (nestedAlias) {
|
package/query/QueryBuilder.js
CHANGED
|
@@ -274,7 +274,9 @@ export class QueryBuilder {
|
|
|
274
274
|
continue;
|
|
275
275
|
}
|
|
276
276
|
filterOptions = QueryHelper.mergePropertyFilters(join.prop.filters, filterOptions);
|
|
277
|
-
|
|
277
|
+
let cond = await em.applyFilters(join.prop.targetMeta.class, join.cond, filterOptions, 'read');
|
|
278
|
+
const criteriaNode = CriteriaNodeFactory.createNode(this.metadata, join.prop.targetMeta.class, cond);
|
|
279
|
+
cond = criteriaNode.process(this, { matchPopulateJoins: true, filter: true, alias: join.alias, ignoreBranching: true, parentPath: join.path });
|
|
278
280
|
if (Utils.hasObjectKeys(cond) || RawQueryFragment.hasObjectFragments(cond)) {
|
|
279
281
|
// remove nested filters, we only care about scalars here, nesting would require another join branch
|
|
280
282
|
for (const key of Object.keys(cond)) {
|
|
@@ -449,6 +449,9 @@ export class QueryBuilderHelper {
|
|
|
449
449
|
}
|
|
450
450
|
const [a, f] = rawField ? [] : this.splitField(key);
|
|
451
451
|
const prop = f && this.getProperty(f, a);
|
|
452
|
+
if (prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
|
|
453
|
+
return { sql: '', params };
|
|
454
|
+
}
|
|
452
455
|
if (op === '$fulltext') {
|
|
453
456
|
/* v8 ignore next */
|
|
454
457
|
if (!prop) {
|
|
@@ -8,7 +8,7 @@ import { QueryBuilder } from './QueryBuilder.js';
|
|
|
8
8
|
export class ScalarCriteriaNode extends CriteriaNode {
|
|
9
9
|
process(qb, options) {
|
|
10
10
|
const matchPopulateJoins = options?.matchPopulateJoins || (this.prop && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind));
|
|
11
|
-
const nestedAlias = qb.getAliasForJoinPath(this.getPath(), { ...options, matchPopulateJoins });
|
|
11
|
+
const nestedAlias = qb.getAliasForJoinPath(this.getPath(options), { ...options, matchPopulateJoins });
|
|
12
12
|
if (this.shouldJoin(qb, nestedAlias)) {
|
|
13
13
|
const path = this.getPath();
|
|
14
14
|
const parentPath = this.parent.getPath(); // the parent is always there, otherwise `shouldJoin` would return `false`
|