@mikro-orm/knex 6.3.7-dev.4 → 6.3.7-dev.6

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.
@@ -135,6 +135,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
135
135
  .indexHint(options.indexHint)
136
136
  .comment(options.comments)
137
137
  .hintComment(options.hintComments);
138
+ qb.where(where);
138
139
  const { first, last, before, after } = options;
139
140
  const isCursorPagination = [first, last, before, after].some(v => v != null);
140
141
  if (type !== query_1.QueryType.COUNT) {
@@ -149,7 +150,6 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
149
150
  }
150
151
  qb.limit(options?.limit, options?.offset);
151
152
  }
152
- qb.where(where);
153
153
  const kqb = qb.getKnexQuery(false).clear('select');
154
154
  if (type === query_1.QueryType.COUNT) {
155
155
  kqb.select(this.connection.getKnex().raw('count(*) as count'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.3.7-dev.4",
3
+ "version": "6.3.7-dev.6",
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,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.3.6"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.3.7-dev.4",
69
+ "@mikro-orm/core": "6.3.7-dev.6",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -223,22 +223,13 @@ class QueryBuilderHelper {
223
223
  const alias = join.inverseAlias ?? join.alias;
224
224
  join.cond[`${alias}.${typeProperty}`] = join.prop.targetMeta.discriminatorValue;
225
225
  }
226
- for (const key of Object.keys(join.cond)) {
227
- const hasPrefix = key.includes('.') || core_1.Utils.isOperator(key) || core_1.RawQueryFragment.isKnownFragment(key);
228
- const newKey = hasPrefix ? key : `${join.alias}.${key}`;
229
- const clause = this.processJoinClause(newKey, join.cond[key], join.alias, params);
230
- /* istanbul ignore else */
231
- if (clause !== '()') {
232
- conditions.push(clause);
233
- }
234
- }
235
226
  let sql = method + ' ';
236
227
  if (join.nested) {
237
228
  sql += `(${this.knex.ref(table)} as ${this.knex.ref(join.alias)}`;
238
229
  for (const nested of join.nested) {
239
230
  const { sql: nestedSql, params: nestedParams } = this.createJoinExpression(nested, joins, schema);
240
231
  sql += ' ' + nestedSql;
241
- params.unshift(...nestedParams);
232
+ params.push(...nestedParams);
242
233
  }
243
234
  sql += `)`;
244
235
  }
@@ -248,6 +239,15 @@ class QueryBuilderHelper {
248
239
  else {
249
240
  sql += `${this.knex.ref(table)} as ${this.knex.ref(join.alias)}`;
250
241
  }
242
+ for (const key of Object.keys(join.cond)) {
243
+ const hasPrefix = key.includes('.') || core_1.Utils.isOperator(key) || core_1.RawQueryFragment.isKnownFragment(key);
244
+ const newKey = hasPrefix ? key : `${join.alias}.${key}`;
245
+ const clause = this.processJoinClause(newKey, join.cond[key], join.alias, params);
246
+ /* istanbul ignore else */
247
+ if (clause !== '()') {
248
+ conditions.push(clause);
249
+ }
250
+ }
251
251
  if (conditions.length > 0) {
252
252
  sql += ` on ${conditions.join(' and ')}`;
253
253
  }
@@ -321,7 +321,7 @@ class QueryBuilderHelper {
321
321
  }
322
322
  mapJoinColumns(type, join) {
323
323
  if (join.prop && [core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(join.prop.kind)) {
324
- return join.prop.fieldNames.map((fieldName, idx) => {
324
+ return join.prop.fieldNames.map((_fieldName, idx) => {
325
325
  const columns = join.prop.owner ? join.joinColumns : join.inverseJoinColumns;
326
326
  return this.mapper(`${join.alias}.${columns[idx]}`, type, undefined, `${join.alias}__${columns[idx]}`);
327
327
  });