@mikro-orm/knex 5.8.10-dev.4 → 5.8.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/AbstractSqlDriver.js +1 -1
- package/package.json +5 -5
- package/query/QueryBuilder.d.ts +5 -1
- package/query/QueryBuilder.js +6 -3
package/AbstractSqlDriver.js
CHANGED
|
@@ -543,7 +543,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
543
543
|
join.schema = options.schema;
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
|
-
const items = owners.length ? await this.rethrow(qb.execute('all')) : [];
|
|
546
|
+
const items = owners.length ? await this.rethrow(qb.execute('all', { mergeResults: false })) : [];
|
|
547
547
|
const map = {};
|
|
548
548
|
const pkProps = ownerMeta.getPrimaryProps();
|
|
549
549
|
owners.forEach(owner => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "5.8.10
|
|
3
|
+
"version": "5.8.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",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"sqlstring": "2.3.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@mikro-orm/core": "^5.8.
|
|
66
|
+
"@mikro-orm/core": "^5.8.10"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "5.
|
|
70
|
-
"@mikro-orm/entity-generator": "5.
|
|
71
|
-
"@mikro-orm/migrations": "5.
|
|
69
|
+
"@mikro-orm/core": "^5.0.0",
|
|
70
|
+
"@mikro-orm/entity-generator": "^5.0.0",
|
|
71
|
+
"@mikro-orm/migrations": "^5.0.0",
|
|
72
72
|
"better-sqlite3": "*",
|
|
73
73
|
"mssql": "*",
|
|
74
74
|
"mysql": "*",
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ import type { AbstractSqlDriver } from '../AbstractSqlDriver';
|
|
|
7
7
|
import { QueryBuilderHelper, type Alias } from './QueryBuilderHelper';
|
|
8
8
|
import type { SqlEntityManager } from '../SqlEntityManager';
|
|
9
9
|
import type { Field } from '../typings';
|
|
10
|
+
export interface ExecuteOptions {
|
|
11
|
+
mapResults?: boolean;
|
|
12
|
+
mergeResults?: boolean;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* SQL query builder with fluent interface.
|
|
12
16
|
*
|
|
@@ -177,7 +181,7 @@ export declare class QueryBuilder<T extends object = AnyEntity> {
|
|
|
177
181
|
* Executes this QB and returns the raw results, mapped to the property names (unless disabled via last parameter).
|
|
178
182
|
* Use `method` to specify what kind of result you want to get (array/single/meta).
|
|
179
183
|
*/
|
|
180
|
-
execute<U = any>(method?: 'all' | 'get' | 'run',
|
|
184
|
+
execute<U = any>(method?: 'all' | 'get' | 'run', options?: ExecuteOptions | boolean): Promise<U>;
|
|
181
185
|
/**
|
|
182
186
|
* Alias for `qb.getResultList()`
|
|
183
187
|
*/
|
package/query/QueryBuilder.js
CHANGED
|
@@ -461,7 +461,10 @@ class QueryBuilder {
|
|
|
461
461
|
* Executes this QB and returns the raw results, mapped to the property names (unless disabled via last parameter).
|
|
462
462
|
* Use `method` to specify what kind of result you want to get (array/single/meta).
|
|
463
463
|
*/
|
|
464
|
-
async execute(method = 'all',
|
|
464
|
+
async execute(method = 'all', options) {
|
|
465
|
+
options = typeof options === 'boolean' ? { mapResults: options } : (options ?? {});
|
|
466
|
+
options.mergeResults ?? (options.mergeResults = true);
|
|
467
|
+
options.mapResults ?? (options.mapResults = true);
|
|
465
468
|
if (!this.connectionType && method !== 'run' && [enums_1.QueryType.INSERT, enums_1.QueryType.UPDATE, enums_1.QueryType.DELETE, enums_1.QueryType.TRUNCATE].includes(this.type ?? enums_1.QueryType.SELECT)) {
|
|
466
469
|
this.connectionType = 'write';
|
|
467
470
|
}
|
|
@@ -473,7 +476,7 @@ class QueryBuilder {
|
|
|
473
476
|
const type = this.connectionType || (method === 'run' ? 'write' : 'read');
|
|
474
477
|
const res = await this.driver.getConnection(type).execute(query.sql, query.bindings, method, this.context);
|
|
475
478
|
const meta = this.mainAlias.metadata;
|
|
476
|
-
if (!mapResults || !meta) {
|
|
479
|
+
if (!options.mapResults || !meta) {
|
|
477
480
|
await this.em?.storeCache(this._cache, cached, res);
|
|
478
481
|
return res;
|
|
479
482
|
}
|
|
@@ -485,7 +488,7 @@ class QueryBuilder {
|
|
|
485
488
|
if (Array.isArray(res)) {
|
|
486
489
|
const map = {};
|
|
487
490
|
mapped = res.map(r => this.driver.mapResult(r, meta, this._populate, this, map));
|
|
488
|
-
if (joinedProps.length > 0) {
|
|
491
|
+
if (options.mergeResults && joinedProps.length > 0) {
|
|
489
492
|
mapped = this.driver.mergeJoinedResult(mapped, this.mainAlias.metadata, joinedProps);
|
|
490
493
|
}
|
|
491
494
|
}
|