Replies: 3 comments
-
I'm not aware of a way to achieve that in Doctrine ORM. |
Beta Was this translation helpful? Give feedback.
-
Are you looking for #8391 ? |
Beta Was this translation helpful? Give feedback.
-
You're probably looking for view DTO? The idea is you don't pass entities into the view because they (as you've said) allow for N+1. What you can do is pass entity proxies which don't automatically generate additional queries but either require the data to be present or can throw. We did this in a project in a very similar way, the view objects were entity proxies and all the data required needed to be prepared upfront, the view couldn't create DB requests. |
Beta Was this translation helpful? Give feedback.
-
I saw 2 interesting blog posts today:
Is it possible to configure Doctrine ORM in a similar way?
I want to be explicit in my queries. For example, only things that I query in the controller, should be able to be used inside the view.
Also the new
n_plus_one_only
mode that ships with Rails 7 seems interesting. Detecting these type of n+1 issues, log them, and ideally, prevent them completely.Beta Was this translation helpful? Give feedback.
All reactions