@mikro-orm/knex 6.0.5-dev.1 → 6.0.5-dev.10
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/query/QueryBuilder.js +13 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.0.5-dev.
|
|
3
|
+
"version": "6.0.5-dev.10",
|
|
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.0.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.0.5-dev.
|
|
69
|
+
"@mikro-orm/core": "6.0.5-dev.10"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/query/QueryBuilder.js
CHANGED
|
@@ -459,6 +459,10 @@ class QueryBuilder {
|
|
|
459
459
|
return this;
|
|
460
460
|
}
|
|
461
461
|
getKnexQuery(processVirtualEntity = true) {
|
|
462
|
+
if (this.#query) {
|
|
463
|
+
return this.#query.qb;
|
|
464
|
+
}
|
|
465
|
+
this.#query = {};
|
|
462
466
|
this.finalize();
|
|
463
467
|
const qb = this.getQueryBase(processVirtualEntity);
|
|
464
468
|
const type = this.type ?? enums_1.QueryType.SELECT;
|
|
@@ -480,14 +484,14 @@ class QueryBuilder {
|
|
|
480
484
|
core_1.Utils.runIfNotEmpty(() => this._hintComments.forEach(comment => qb.hintComment(comment)), this._hintComments);
|
|
481
485
|
core_1.Utils.runIfNotEmpty(() => this.helper.appendOnConflictClause(type, this._onConflict, qb), this._onConflict);
|
|
482
486
|
if (this.type === enums_1.QueryType.TRUNCATE && this.platform.usesCascadeStatement()) {
|
|
483
|
-
return this.knex.raw(qb.toSQL().toNative().sql + ' cascade');
|
|
487
|
+
return this.#query.qb = this.knex.raw(qb.toSQL().toNative().sql + ' cascade');
|
|
484
488
|
}
|
|
485
489
|
if (this.lockMode) {
|
|
486
490
|
this.helper.getLockSQL(qb, this.lockMode, this.lockTables);
|
|
487
491
|
}
|
|
488
492
|
this.helper.finalize(type, qb, this.mainAlias.metadata, this._data, this._returning);
|
|
489
493
|
this.clearRawFragmentsCache();
|
|
490
|
-
return qb;
|
|
494
|
+
return this.#query.qb = qb;
|
|
491
495
|
}
|
|
492
496
|
/**
|
|
493
497
|
* @internal
|
|
@@ -504,12 +508,15 @@ class QueryBuilder {
|
|
|
504
508
|
}
|
|
505
509
|
#query;
|
|
506
510
|
toQuery() {
|
|
507
|
-
if (this.#query) {
|
|
508
|
-
return this.#query;
|
|
511
|
+
if (this.#query?.sql) {
|
|
512
|
+
return { sql: this.#query.sql, _sql: this.#query._sql, params: this.#query.params };
|
|
509
513
|
}
|
|
510
514
|
const sql = this.getKnexQuery().toSQL();
|
|
511
515
|
const query = sql.toNative();
|
|
512
|
-
|
|
516
|
+
this.#query.sql = query.sql;
|
|
517
|
+
this.#query._sql = sql;
|
|
518
|
+
this.#query.params = query.bindings ?? [];
|
|
519
|
+
return { sql: this.#query.sql, _sql: this.#query._sql, params: this.#query.params };
|
|
513
520
|
}
|
|
514
521
|
/**
|
|
515
522
|
* Returns the list of all parameters for this query.
|
|
@@ -521,7 +528,7 @@ class QueryBuilder {
|
|
|
521
528
|
* Returns raw interpolated query string with all the parameters inlined.
|
|
522
529
|
*/
|
|
523
530
|
getFormattedQuery() {
|
|
524
|
-
const query = this.
|
|
531
|
+
const query = this.getKnexQuery().toSQL();
|
|
525
532
|
return this.platform.formatQuery(query.sql, query.bindings);
|
|
526
533
|
}
|
|
527
534
|
/**
|