Skip to content

Eager relations do not respect relationLoadStrategy #9006

Closed
szlori/typeorm
#1

Description

@serg06

Issue Description

When you specify relationLoadStrategy: 'query' in DataSource:

export const dataSource = new DataSource({
    relationLoadStrategy: 'query',
    ...
});

And then specify eager: true in an Entity relation:

@Entity()
export class UserEntity {
    @OneToMany(() => ProductEntity, product => product.user, {
        eager: true
    }),
    ...
}

And then get one of those entities:

dataSource.getRepository(UserEntity).find({
    take: 1
});

It doesn't respect relationLoadStrategy.

Expected Behavior

The relation is loaded using multiple queries instead of a join.

With logging: true, you see a two separate queries and no LEFT JOIN.

Actual Behavior

The relation is loaded using a join.

With logging: true, you see a single query with a LEFT JOIN on "UserEntity_products"."userId"="UserEntity"."id".

Steps to Reproduce

See Issue Description

My Environment

Dependency Version
TypeORM version 0.3.6

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres yes
react-native no
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

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

  • ✖️ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Activity

  1. added 6 commits that reference this issue on Sep 8, 2022
    1c37a65
    a567f4e
    3a196cf
    8ac091e
    f507f66
    3ec89c3
  2. added a commit that references this issue on Nov 17, 2022
    4158d9a
  3. komo81 commented on Jul 26, 2024

    @komo81

    +1

  4. github-actions commented on Sep 18, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

  5. self-assigned this
    on Mar 22, 2026
  6. added this to the 1.0 milestone on Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions