@mikro-orm/knex 6.0.0-dev.178 → 6.0.0-dev.179

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.0.0-dev.178",
3
+ "version": "6.0.0-dev.179",
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": "^5.9.2"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.0.0-dev.178"
69
+ "@mikro-orm/core": "6.0.0-dev.179"
70
70
  }
71
71
  }
@@ -57,15 +57,25 @@ class CriteriaNodeFactory {
57
57
  }, {});
58
58
  return this.createNode(metadata, entityName, map, node, key);
59
59
  }
60
- const operator = Object.keys(payload[key]).some(f => core_1.Utils.isOperator(f));
60
+ // array operators can be used on embedded properties
61
+ const allowedOperators = ['$contains', '$contained', '$overlap'];
62
+ const operator = Object.keys(payload[key]).some(f => core_1.Utils.isOperator(f) && !allowedOperators.includes(f));
61
63
  if (operator) {
62
64
  throw core_1.ValidationError.cannotUseOperatorsInsideEmbeddables(entityName, prop.name, payload);
63
65
  }
64
66
  const map = Object.keys(payload[key]).reduce((oo, k) => {
65
- if (!prop.embeddedProps[k]) {
67
+ if (!prop.embeddedProps[k] && !allowedOperators.includes(k)) {
66
68
  throw core_1.ValidationError.invalidEmbeddableQuery(entityName, k, prop.type);
67
69
  }
68
- oo[prop.embeddedProps[k].name] = payload[key][k];
70
+ if (prop.embeddedProps[k]) {
71
+ oo[prop.embeddedProps[k].name] = payload[key][k];
72
+ }
73
+ else if (typeof payload[key][k] === 'object') {
74
+ oo[k] = JSON.stringify(payload[key][k]);
75
+ }
76
+ else {
77
+ oo[k] = payload[key][k];
78
+ }
69
79
  return oo;
70
80
  }, {});
71
81
  return this.createNode(metadata, entityName, map, node, key);
@@ -104,7 +104,6 @@ class ObjectCriteriaNode extends CriteriaNode_1.CriteriaNode {
104
104
  }
105
105
  else if (this.isPrefixed(k) || core_1.Utils.isOperator(k) || !childAlias) {
106
106
  const idx = prop.referencedPKs.indexOf(k);
107
- // FIXME maybe other kinds should be supported too?
108
107
  const key = idx !== -1 && !childAlias && ![core_1.ReferenceKind.ONE_TO_MANY, core_1.ReferenceKind.MANY_TO_MANY].includes(prop.kind) ? prop.joinColumns[idx] : k;
109
108
  if (key in o) {
110
109
  const $and = o.$and ?? [];