-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix NoMethodError preparable for Arel::Visitors::PostgreSQL #22748
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks! Can you add a test? |
Just wanted to say that this is a genuine issue with Postgresql which you can reproduce by setting Tested with |
@adityashedge Yeah That's right. But our system has much complex queries which don't work with |
@Azzurrio Nothing has changed on this since his original comment. This needs a test. |
@Azzurrio I imagine pretty much any test that does a query will work to exercise this. Personally, I'd look for other tests that temporarily vary the connection configuration. |
efe08fb
to
4460b63
Compare
@sgrif Just a reminder, Is this missing something else? |
👍 |
fixtures :developers | ||
|
||
def setup | ||
Developer.connection_config[:prepared_statements] = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pollutes the config for subsequent tests; we need a teardown that puts it back how it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewd done! 👍
@matthewd Are we done with this? |
Sorry... is it really |
@matthewd yeah it was unset which defaults to |
We should probably just store the existing value in a variable then put it back afterwards, so this test doesn't have any knowledge of what the default is. (Technically we'd be changing it from not-present to explicitly-nil, but I think it's safe to pretend those are the same.) |
@matthewd Okay done 👍 |
Fix NoMethodError preparable for Arel::Visitors::PostgreSQL
Thanks ❤️ |
- Due to `assert_nothing_raised` this test was not really testing anything. - So updated it to assert that the query gives expected result. - Also in general we can use `connection.unprepared_statement` for testing queries w/o prepared statements but it can't be used in this case. This test cases was added because when prepared_statements config is set to false, then DetermineIfPreparableVisitor module does not extended by Arel visitor resulting into an error. Ref: rails#22748. - Because DetermineIfPreparableVisitor module does not get added to the visitor chain only if prepared_statements is false while **setting up connection**, not when `unprepared_statement` is used. - I have also added an assertion for making sure that prepared_config is set to false from the start, so that nobody accidentally removes the connection setup using `arunit_without_prepared_statements` and replaces it with stubs or unprepared_statement.
After upgrading to
5.0.0.beta1
I got an error calledSo I did debug the problem and I found that module
DetermineIfPreparableVisitor
is extended only in case database configs forprepared_statements
is true.for that, I did that to fix the problem, and it works fine now 👍