@mikro-orm/knex 6.1.13-dev.3 → 6.1.13-dev.5
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 +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.1.13-dev.
|
|
3
|
+
"version": "6.1.13-dev.5",
|
|
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.1.12"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.1.13-dev.
|
|
69
|
+
"@mikro-orm/core": "6.1.13-dev.5"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/query/QueryBuilder.js
CHANGED
|
@@ -598,14 +598,14 @@ class QueryBuilder {
|
|
|
598
598
|
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)) {
|
|
599
599
|
this.connectionType = 'write';
|
|
600
600
|
}
|
|
601
|
+
if (!this.finalized && method === 'get' && this.type === enums_1.QueryType.SELECT) {
|
|
602
|
+
this.limit(1);
|
|
603
|
+
}
|
|
601
604
|
const query = this.toQuery()._sql;
|
|
602
605
|
const cached = await this.em?.tryCache(this.mainAlias.entityName, this._cache, ['qb.execute', query.sql, query.bindings, method]);
|
|
603
606
|
if (cached?.data) {
|
|
604
607
|
return cached.data;
|
|
605
608
|
}
|
|
606
|
-
if (!this.finalized && method === 'get') {
|
|
607
|
-
this.limit(1);
|
|
608
|
-
}
|
|
609
609
|
const write = method === 'run' || !this.platform.getConfig().get('preferReadReplicas');
|
|
610
610
|
const type = this.connectionType || (write ? 'write' : 'read');
|
|
611
611
|
const res = await this.driver.getConnection(type).execute(query.sql, query.bindings, method, this.context, this.loggerContext);
|