@mikro-orm/sql 7.2.6-dev.41 → 7.2.6-dev.43

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/sql",
3
- "version": "7.2.6-dev.41",
3
+ "version": "7.2.6-dev.43",
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",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.2.5"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.6-dev.41"
56
+ "@mikro-orm/core": "7.2.6-dev.43"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -1569,6 +1569,19 @@ export class QueryBuilder {
1569
1569
  if (prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
1570
1570
  return;
1571
1571
  }
1572
+ // the joined strategy selects by column name, which can collide with the name of another property
1573
+ const shadowed = customAlias &&
1574
+ prop &&
1575
+ (prop.kind === ReferenceKind.EMBEDDED ||
1576
+ (customAlias.endsWith(`__${f}`) && (prop.persist === false || !prop.fieldNames.includes(f)))) &&
1577
+ (this.#state.aliases[a]?.meta ?? this.mainAlias.meta).props.some(p => p !== prop &&
1578
+ p.persist !== false &&
1579
+ (p.kind !== ReferenceKind.EMBEDDED || p.object) &&
1580
+ p.fieldNames?.includes(f));
1581
+ if (shadowed) {
1582
+ ret.push(raw('?? as ??', [`${a}.${f}`, customAlias]));
1583
+ return;
1584
+ }
1572
1585
  if (prop?.persist === false && !prop.embedded && !prop.formula && type === 'where') {
1573
1586
  return;
1574
1587
  }
@@ -1578,11 +1591,7 @@ export class QueryBuilder {
1578
1591
  ret.push(getFieldName(aliased, customAlias));
1579
1592
  return;
1580
1593
  }
1581
- // the joined strategy selects by column name, which can collide with an inline embedded property name
1582
- const shadowed = customAlias &&
1583
- prop?.kind === ReferenceKind.EMBEDDED &&
1584
- (this.#state.aliases[a]?.meta ?? this.mainAlias.meta).props.some(p => (p.kind !== ReferenceKind.EMBEDDED || p.object) && p.fieldNames?.includes(f));
1585
- if (prop?.kind === ReferenceKind.EMBEDDED && !shadowed) {
1594
+ if (prop?.kind === ReferenceKind.EMBEDDED) {
1586
1595
  if (customAlias) {
1587
1596
  throw new Error(`Cannot use 'as ${customAlias}' alias on embedded property '${field}' because it expands to multiple columns. Alias individual fields instead (e.g. '${field}.propertyName as ${customAlias}').`);
1588
1597
  }