preventsLazyLoading only works with multiple records? #45328
Unanswered
frits-metalogix
asked this question in
Q&A
Replies: 2 comments
-
This is also really bothering me. I don't get it :( |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yeah. Having this count check is really hinders in tests. This flag is intended to solve N+1 problem and only this problem. Someone decided, that 1+1 would be 1+1 in no mater, would you eager load relations, or lazy load them, and it isn't a problem. And this is a drawback of it's name preventsLazyLoading and not a solveNPlusOne, and it doesn't really helps in solving that problem. But it's better then nothing. You just have to remember to always create a bunch of objects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It looks like preventsLazyLoading is only enforced for multiple records? I've tried enforcing it in a test with only one record entered into the database, my colleague had an issue related to this in our QA environment when he was using an API, he had multiple records. I don't think I've come accross this in the docs, or maybe this can be removed, the DX felt a bit weird? Hope I don't come off as winy.
framework/src/Illuminate/Database/Eloquent/Builder.php
Line 399 in 442626c
Beta Was this translation helpful? Give feedback.
All reactions