@mikro-orm/knex 6.0.0-dev.72 → 6.0.0-dev.74

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.0.0-dev.72",
3
+ "version": "6.0.0-dev.74",
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": "^5.7.6"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "~6.0.0-dev.72"
69
+ "@mikro-orm/core": "~6.0.0-dev.74"
70
70
  }
71
71
  }
@@ -616,11 +616,15 @@ class QueryBuilder {
616
616
  joinReference(field, alias, cond, type, path) {
617
617
  this.ensureNotFinalized();
618
618
  const [fromAlias, fromField] = this.helper.splitField(field);
619
- const entityName = this._aliases[fromAlias]?.entityName;
619
+ const q = (str) => `'${str}'`;
620
+ if (!this._aliases[fromAlias]) {
621
+ throw new Error(`Trying to join ${q(fromField)} with alias ${q(fromAlias)}, but ${q(fromAlias)} is not a known alias. Available aliases are: ${Object.keys(this._aliases).map(q).join(', ')}.`);
622
+ }
623
+ const entityName = this._aliases[fromAlias].entityName;
620
624
  const meta = this.metadata.get(entityName);
621
625
  const prop = meta.properties[fromField];
622
626
  if (!prop) {
623
- throw new Error(`Trying to join ${field}, but ${fromField} is not a defined relation on ${meta.className}`);
627
+ throw new Error(`Trying to join ${q(field)}, but ${q(fromField)} is not a defined relation on ${meta.className}.`);
624
628
  }
625
629
  this.createAlias(prop.type, alias);
626
630
  cond = core_1.QueryHelper.processWhere({
@@ -865,8 +869,8 @@ class QueryBuilder {
865
869
  core_1.QueryHelper.processObjectParams(this._data);
866
870
  core_1.QueryHelper.processObjectParams(this._cond);
867
871
  core_1.QueryHelper.processObjectParams(this._having);
868
- // automatically enable paginate flag when we detect to-many joins
869
- if (!this.flags.has(core_1.QueryFlag.DISABLE_PAGINATE) && this.hasToManyJoins()) {
872
+ // automatically enable paginate flag when we detect to-many joins, but only if there is no `group by` clause
873
+ if (!this.flags.has(core_1.QueryFlag.DISABLE_PAGINATE) && this._groupBy.length === 0 && this.hasToManyJoins()) {
870
874
  this.flags.add(core_1.QueryFlag.PAGINATE);
871
875
  }
872
876
  if (meta && this.flags.has(core_1.QueryFlag.PAGINATE) && (this._limit > 0 || this._offset > 0)) {