We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug If I specify the strategy on a ManyToOne to be joined, the query doesn't do a join to load.
strategy
ManyToOne
Stack trace N/A
To Reproduce Steps to reproduce the behavior:
Consider the following entities:
@Entity() export default class Order { @PrimaryKey() id!: number; @OneToMany(() => OrderItem, ({ order }) => order) orderItems = new Collection<OrderItem>(this); } @Entity() export default class OrderItem { @PrimaryKey() id!: number; @ManyToOne({ entity: () => Order, strategy: LoadStrategy.JOINED, eager: true }) order!: Order; }
Finally, run a query to pull order items:
orm.em.getRepository<OrderItem>('OrderItem').find({ id: { $gt: 100 } })
The generated query is:
select "e0".* from "order_item" as "e0" where "e0"."id" > 100
Expected behavior There should be a join in the query to populate the Order entity.
Order
Additional context Specifying populate directly in the query does produce the join:
orm.em .getRepository<OrderItem>('OrderItem') .find({ id: { $gt: 100 } }, { populate: { order: LoadStrategy.JOINED } });
select "e0"."id", "e0"."order_id", "o1"."id" as "o1__id" from "order_item" as "e0" left join "order" as "o1" on "e0"."order_id" = "o1"."id" where "e0"."id" > 100
Versions
The text was updated successfully, but these errors were encountered:
I think this is more about combining strategy with eager: true (eager loading is implemented as automatically filling the populate for you).
eager: true
populate
Sorry, something went wrong.
Just FYI, I tried it with only eager: true and omitted the load strategy and I had the same result, no join.
@ManyToOne({ entity: () => Order, eager: true })
897c7bd
B4nan
No branches or pull requests
Describe the bug
If I specify the
strategy
on aManyToOne
to be joined, the query doesn't do a join to load.Stack trace
N/A
To Reproduce
Steps to reproduce the behavior:
Consider the following entities:
Finally, run a query to pull order items:
The generated query is:
Expected behavior
There should be a join in the query to populate the
Order
entity.Additional context
Specifying populate directly in the query does produce the join:
Versions
The text was updated successfully, but these errors were encountered: