Skip to content

Alias Issue With Nested Entity And Relations #9944

@felix-gohla

Description

@felix-gohla

Issue description

Querying a nested entity which in turn has deeply nested relationships (eager) results in error (since 0.3.13)

Expected Behavior

Consider the following example entities

  • A has a nested entity B
  • B has a OneToMany Relationship To C (eager)
  • C has a OneToMany Relationship To D (eager)

Querying A should resolve all relations just fine without any error.

Actual Behavior

Querying A results in the following error: TypeORMError: "A__b" alias was not found. Maybe you forgot to join it?

Steps to reproduce

  1. Clone the reproduction repo
  2. Follow the steps in the README there and see the error code.

My Environment

Dependency Version
Operating System macOS 13.3
Node.js version 19.8.1
Typescript version 4.5.2
TypeORM version ^0.3.13

Additional Context

This issue does not occur with typeorm < 0.3.13, so the issue has been introduced since 0.3.12.
It also does not happen when only having one level of relations (i.e. without entity D it works).

First investigations did show, that a11809e could be the culprit (especially https://github.com/typeorm/typeorm/blame/master/src/find-options/FindOptionsUtils.ts#LL390-L395) which was merged in #9680.

I only tested this with postgres.

If desired, I could provide the reproduction as a test but I am not sure how to fix this.

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions