@mikro-orm/mariadb 7.1.6-dev.9 → 7.1.6

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.
@@ -1,4 +1,4 @@
1
- import { isRaw, raw, RawQueryFragment, Utils, } from '@mikro-orm/core';
1
+ import { raw, RawQueryFragment, Utils } from '@mikro-orm/core';
2
2
  import { QueryBuilder } from '@mikro-orm/mysql';
3
3
  /**
4
4
  * @inheritDoc
@@ -16,7 +16,6 @@ export class MariaDbQueryBuilder extends QueryBuilder {
16
16
  if (this.state.offset) {
17
17
  subQuery.offset(this.state.offset);
18
18
  }
19
- const addToSelect = [];
20
19
  if (this.state.orderBy.length > 0) {
21
20
  const orderBy = [];
22
21
  for (const orderMap of this.state.orderBy) {
@@ -30,38 +29,18 @@ export class MariaDbQueryBuilder extends QueryBuilder {
30
29
  const prop = this.helper.getProperty(f, a);
31
30
  const type = this.platform.castColumn(prop);
32
31
  const fieldName = this.helper.mapper(field, this.type, undefined, null);
33
- if (!prop?.persist && !prop?.formula && !pks.includes(fieldName)) {
34
- addToSelect.push(fieldName);
35
- }
36
- const key = raw(`min(${this.platform.quoteIdentifier(fieldName)}${type})`);
37
- orderBy.push({ [key]: direction });
32
+ // virtual fields (e.g. `qb.as(...)`) have no column to reference inside `min()`; inline their expression
33
+ const virtual = !prop?.persist && !prop?.formula && !pks.includes(fieldName)
34
+ ? this.resolveVirtualField(f, fieldName)
35
+ : undefined;
36
+ const expr = virtual ? virtual.expr : this.platform.quoteIdentifier(fieldName);
37
+ orderBy.push({ [raw(`min(${expr}${type})`)]: direction });
38
38
  }
39
39
  }
40
40
  subQuery.orderBy(orderBy);
41
41
  }
42
42
  subQuery.state.finalized = true;
43
43
  const innerQuery = subQuery.as(this.mainAlias.aliasName).clear('select').select(pks);
44
- /* v8 ignore next */
45
- if (addToSelect.length > 0) {
46
- addToSelect.forEach(prop => {
47
- const field = this.state.fields.find(field => {
48
- if (typeof field === 'object' && field && '__as' in field) {
49
- return field.__as === prop;
50
- }
51
- if (isRaw(field)) {
52
- // not perfect, but should work most of the time, ideally we should check only the alias (`... as alias`)
53
- return field.sql.includes(prop);
54
- }
55
- return false;
56
- });
57
- if (isRaw(field)) {
58
- innerQuery.select(this.platform.formatQuery(field.sql, field.params));
59
- }
60
- else if (field) {
61
- innerQuery.select(field);
62
- }
63
- });
64
- }
65
44
  // multiple sub-queries are needed to get around mysql limitations with order by + limit + where in + group by (o.O)
66
45
  // https://stackoverflow.com/questions/17892762/mysql-this-version-of-mysql-doesnt-yet-support-limit-in-all-any-some-subqu
67
46
  const subSubQuery = this.platform.createNativeQueryBuilder();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mariadb",
3
- "version": "7.1.6-dev.9",
3
+ "version": "7.1.6",
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
  "keywords": [
6
6
  "data-mapper",
@@ -47,14 +47,14 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/mysql": "7.1.6-dev.9",
51
- "kysely": "0.29.2"
50
+ "@mikro-orm/mysql": "7.1.6",
51
+ "kysely": "0.29.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@mikro-orm/core": "^7.1.5"
54
+ "@mikro-orm/core": "^7.1.6"
55
55
  },
56
56
  "peerDependencies": {
57
- "@mikro-orm/core": "7.1.6-dev.9"
57
+ "@mikro-orm/core": "7.1.6"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">= 22.17.0"