-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
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
Query hook before execution #93
Comments
Can you give an example of what you would like to modify? |
I'd like to allow something along the lines of: AlbumSerializer.page(params, Albums.where("year < 1950")) do |query|
# query has not been executed yet
results = Albums.transaction do
# Query whatever you want
SomeModel.some_query
next query.load
end
# Do something with results, or not
next results
end From what i've seen, we would at least need to defer sideloading queries (use eager_load ?) until callback has been called. |
Thanks. I can't yet think of a reason why I'd need this in my applications. What's your use case? |
For example, wrap the query in a transaction (like above). Separating query parsing/generation/execution would also help to plug other DB adapters (Elasticsearch for example), but that's probably outside the scope of this issue. Maybe explaining the full use case would help to to make this clearer : Thank you for your answers. |
I need to alter the query made by methods such as
page
andresource
before execution, to gain finer control over transactions, for example.Do you support inclusion of this feature into your project ?
I'd be willing to discusss technical details and PR.
The text was updated successfully, but these errors were encountered: