@mikro-orm/knex 6.0.0-dev.71 → 6.0.0-dev.73

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.
@@ -795,6 +795,10 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
795
795
  }
796
796
  return;
797
797
  }
798
+ if (prop.formula) {
799
+ ret.push(prop.name);
800
+ return;
801
+ }
798
802
  if (prop.fieldNames) {
799
803
  ret.push(...prop.fieldNames);
800
804
  }
package/index.mjs CHANGED
@@ -12,6 +12,7 @@ export const AbstractSqlPlatform = mod.AbstractSqlPlatform;
12
12
  export const AfterCreate = mod.AfterCreate;
13
13
  export const AfterDelete = mod.AfterDelete;
14
14
  export const AfterUpdate = mod.AfterUpdate;
15
+ export const AfterUpsert = mod.AfterUpsert;
15
16
  export const ArrayCollection = mod.ArrayCollection;
16
17
  export const ArrayCriteriaNode = mod.ArrayCriteriaNode;
17
18
  export const ArrayType = mod.ArrayType;
@@ -19,6 +20,7 @@ export const BaseEntity = mod.BaseEntity;
19
20
  export const BeforeCreate = mod.BeforeCreate;
20
21
  export const BeforeDelete = mod.BeforeDelete;
21
22
  export const BeforeUpdate = mod.BeforeUpdate;
23
+ export const BeforeUpsert = mod.BeforeUpsert;
22
24
  export const BigIntType = mod.BigIntType;
23
25
  export const BlobType = mod.BlobType;
24
26
  export const BooleanType = mod.BooleanType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.0.0-dev.71",
3
+ "version": "6.0.0-dev.73",
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,9 +63,9 @@
63
63
  "sqlstring": "2.3.3"
64
64
  },
65
65
  "devDependencies": {
66
- "@mikro-orm/core": "^5.7.2"
66
+ "@mikro-orm/core": "^5.7.6"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "~6.0.0-dev.71"
69
+ "@mikro-orm/core": "~6.0.0-dev.73"
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)) {