@mikro-orm/knex 6.1.13-dev.1 → 6.1.13-dev.2

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.1.13-dev.1",
3
+ "version": "6.1.13-dev.2",
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.1"
69
+ "@mikro-orm/core": "6.1.13-dev.2"
70
70
  }
71
71
  }
@@ -603,6 +603,9 @@ class QueryBuilder {
603
603
  if (cached?.data) {
604
604
  return cached.data;
605
605
  }
606
+ if (!this.finalized && method === 'get') {
607
+ this.limit(1);
608
+ }
606
609
  const write = method === 'run' || !this.platform.getConfig().get('preferReadReplicas');
607
610
  const type = this.connectionType || (write ? 'write' : 'read');
608
611
  const res = await this.driver.getConnection(type).execute(query.sql, query.bindings, method, this.context, this.loggerContext);
@@ -674,6 +677,9 @@ class QueryBuilder {
674
677
  * Executes the query, returning the first result or null
675
678
  */
676
679
  async getSingleResult() {
680
+ if (!this.finalized) {
681
+ this.limit(1);
682
+ }
677
683
  const [res] = await this.getResultList(1);
678
684
  return res || null;
679
685
  }