@mikro-orm/knex 6.0.0-dev.19 → 6.0.0-dev.20

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.19",
3
+ "version": "6.0.0-dev.20",
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",
@@ -59,13 +59,13 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "fs-extra": "11.1.0",
62
- "knex": "2.3.0",
62
+ "knex": "2.4.0",
63
63
  "sqlstring": "2.3.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@mikro-orm/core": "^5.6.3"
66
+ "@mikro-orm/core": "^5.6.4"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "~6.0.0-dev.19"
69
+ "@mikro-orm/core": "~6.0.0-dev.20"
70
70
  }
71
71
  }
@@ -36,6 +36,17 @@ class QueryBuilderHelper {
36
36
  parts.push(this.mapper(a !== this.alias ? `${a}.${f}` : f, type, value, alias));
37
37
  }
38
38
  }
39
+ // flatten the value if we see we are expanding nested composite key
40
+ // hackish, but cleaner solution would require quite a lot of refactoring
41
+ if (fields.length !== parts.length && Array.isArray(value)) {
42
+ value.forEach(row => {
43
+ if (Array.isArray(row)) {
44
+ const tmp = core_1.Utils.flatten(row);
45
+ row.length = 0;
46
+ row.push(...tmp);
47
+ }
48
+ });
49
+ }
39
50
  return this.knex.raw('(' + parts.map(part => this.knex.ref(part)).join(', ') + ')');
40
51
  }
41
52
  let ret = field;
@@ -72,7 +83,8 @@ class QueryBuilderHelper {
72
83
  ret += ' as ' + alias;
73
84
  }
74
85
  if (customExpression) {
75
- return this.knex.raw(ret, value);
86
+ const bindings = core_1.Utils.asArray(value).slice(0, ret.match(/\?/g)?.length ?? 0);
87
+ return this.knex.raw(ret, bindings);
76
88
  }
77
89
  if (!isTableNameAliasRequired || this.isPrefixed(ret) || noPrefix) {
78
90
  return ret;
@@ -394,7 +406,8 @@ class QueryBuilderHelper {
394
406
  }));
395
407
  }
396
408
  else {
397
- qb[m](this.mapper(key, type, undefined, null), replacement, value[op]);
409
+ const mappedKey = this.mapper(key, type, value[op], null);
410
+ qb[m](mappedKey, replacement, value[op]);
398
411
  }
399
412
  }
400
413
  getOperatorReplacement(op, value) {