Replies: 1 comment 6 replies
-
Thank you for providing feedback. The way the forbid_lazy_load plugin works is:
So the documentation isn't wrong. You can forbid lazy loading for objects that would allow it by default, and you can allow lazy load on objects that would forbid it by default There currently isn't a way to configure the plugin to not automatically forbid lazy loading when retrieving multiple objects. However, can you try the following and let me know if it works the way you want?: Sequel::Plugins::ForbidLazyLoad::DatasetMethods.class_exec do
remove_method(:each)
remove_method(:with_sql_each)
end |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We're in a situation right now where we've got dozens of Sequel models, aren't eager loading anything, but would like to be. There's so much existing code though that there's no way feasible way to start doing it everywhere all at once, so we'll need an incremental approach.
I read the
ForbidLazyLoad
plugin's documentation a couple times, and I'm a bit confused by some aspects. It seems to suggest that it should be possible to forbid lazy load for specific objects:But then the next paragraph seems to suggest that any use of
.all
might forbid lazy loading anywhere (and not just on objects where it's set):I tried activating the plugin via:
Then trying to use it only in a couple specific places at first where I've started to put together the right
eager
invocations:When I run the test suite for this specific route it does exactly what I expect. It passes in the state above, and if I forget an eager directive that needs to be there, I get an error telling me about it.
However, when I run other parts of the test suite that start loading one of these models through an association, I also get
Sequel::Plugins::ForbidLazyLoad::Error
, despite never having activatedforbid_lazy_load
in that part of the test suite:What I'm hoping to accomplish is to be able to turn this on test by test as I add
eager
directives, but not have to do everything at once. Is there any way to accomplish that, or am I out of luck? Thanks.Beta Was this translation helpful? Give feedback.
All reactions