@mikro-orm/sql 7.2.1 → 7.2.2-dev.1

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.1",
3
+ "version": "7.2.2-dev.1",
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.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.1"
56
+ "@mikro-orm/core": "7.2.2-dev.1"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -1576,16 +1576,22 @@ export class QueryBuilder {
1576
1576
  ret.push(getFieldName(aliased, customAlias));
1577
1577
  return;
1578
1578
  }
1579
- if (prop?.kind === ReferenceKind.EMBEDDED) {
1579
+ // the joined strategy selects by column name, which can collide with an inline embedded property name
1580
+ const shadowed = customAlias &&
1581
+ prop?.kind === ReferenceKind.EMBEDDED &&
1582
+ (this.#state.aliases[a]?.meta ?? this.mainAlias.meta).props.some(p => (p.kind !== ReferenceKind.EMBEDDED || p.object) && p.fieldNames?.includes(f));
1583
+ if (prop?.kind === ReferenceKind.EMBEDDED && !shadowed) {
1580
1584
  if (customAlias) {
1581
1585
  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}').`);
1582
1586
  }
1583
1587
  const nest = (prop) => {
1584
1588
  for (const childProp of Object.values(prop.embeddedProps)) {
1585
- if (childProp.fieldNames &&
1586
- (childProp.kind !== ReferenceKind.EMBEDDED || childProp.object) &&
1587
- childProp.persist !== false) {
1588
- ret.push(getFieldName(childProp.fieldNames[0]));
1589
+ if (childProp.persist === false) {
1590
+ continue;
1591
+ }
1592
+ if (childProp.fieldNames && (childProp.kind !== ReferenceKind.EMBEDDED || childProp.object)) {
1593
+ const name = childProp.fieldNames[0];
1594
+ ret.push(getFieldName(this.#state.aliases[a] ? `${a}.${name}` : name));
1589
1595
  }
1590
1596
  else {
1591
1597
  nest(childProp);