@mikro-orm/knex 6.1.7-dev.1 → 6.1.7-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/knex",
3
- "version": "6.1.7-dev.1",
3
+ "version": "6.1.7-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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -66,6 +66,6 @@
66
66
  "@mikro-orm/core": "^6.1.6"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.1.7-dev.1"
69
+ "@mikro-orm/core": "6.1.7-dev.3"
70
70
  }
71
71
  }
@@ -18,10 +18,13 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
18
18
  }
19
19
  if (this.shouldAutoJoin(qb, nestedAlias)) {
20
20
  if (keys.some(k => ['$some', '$none', '$every'].includes(k))) {
21
- // ignore collection operators when used on a non-relational property - this can happen when they get into
22
- // populateWhere via `infer` on m:n properties with select-in strategy
23
- if (!this.prop?.targetMeta) {
24
- return {};
21
+ if (![core_1.ReferenceKind.MANY_TO_MANY, core_1.ReferenceKind.ONE_TO_MANY].includes(this.prop.kind)) {
22
+ // ignore collection operators when used on a non-relational property - this can happen when they get into
23
+ // populateWhere via `infer` on m:n properties with select-in strategy
24
+ if (this.parent?.parent) { // we validate only usage on top level
25
+ return {};
26
+ }
27
+ throw new Error(`Collection operators can be used only inside a collection property context, but it was used for ${this.getPath()}.`);
25
28
  }
26
29
  const $and = [];
27
30
  const knownKey = [core_1.ReferenceKind.SCALAR, core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.EMBEDDED].includes(this.prop.kind) || (this.prop.kind === core_1.ReferenceKind.ONE_TO_ONE && this.prop.owner);