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 has_one
enum
where
queries
#25146
Conversation
5aa3ba7
to
da2a474
Compare
if association && !association.polymorphic? | ||
association_klass = association.klass | ||
arel_table = association_klass.arel_table.alias(table_name) | ||
# First check what is passed in, and see if an associationexists in |
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.
need a space here: associationexists
.
@@ -44,17 +44,21 @@ def associated_with?(association_name) | |||
def associated_table(table_name) | |||
return self if table_name == arel_table.name | |||
|
|||
association = klass._reflect_on_association(table_name) |
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.
Seems like this entire PR could be simplified to just changing this line to
association = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize)
b1560d5
to
a47794e
Compare
👍 updated @sgrif |
if association && !association.polymorphic? | ||
association_klass = association.klass | ||
arel_table = association_klass.arel_table.alias(table_name) | ||
arel_table = association_klass.arel_table.alias(table_name.to_s.pluralize) |
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.
The pluralize
isn't needed
👍 updated again @sgrif :) |
👍 |
Fix `has_one` `enum` `where` queries
Backport #25146 to 5-0-stable
In the following: rails/rails#25146 Rails added a regression to making nested joins with references to those joins in the WHERE clause, and this causes an error when running this test suite in Rails 5.0.1. This has been addressed in Rails with: rails/rails#27598 And has been merged into master, but it is likely that Rails 5.0.1 will not be pulled from Rubygems, and the ManageIQ will fail to run tests properly with that version of Rails. Because of that, and to allow the tests to function in the same way, the simplest thing to do is to stringify the keys manually avoid the error for now. This is against the convention (most Rails devs prefer symbols), but this allows the tests to remain as they were.
In the following: rails/rails#25146 Rails added a regression to making nested joins with references to those joins in the WHERE clause, and this causes an error when running this test suite in Rails 5.0.1. This has been addressed in Rails with: rails/rails#27598 And has been merged into master, but it is likely that Rails 5.0.1 will not be pulled from Rubygems, and the ManageIQ will fail to run tests properly with that version of Rails. Because of that, and to allow the tests to function in the same way, the simplest thing to do is to stringify the keys manually avoid the error for now. This is against the convention (most Rails devs prefer symbols), but this allows the tests to remain as they were.
In the following: rails/rails#25146 Rails added a regression to making nested joins with references to those joins in the WHERE clause, and this causes an error when running this test suite in Rails 5.0.1. This has been addressed in Rails with: rails/rails#27598 And has been merged into master, but it is likely that Rails 5.0.1 will not be pulled from Rubygems, and the ManageIQ will fail to run tests properly with that version of Rails. Because of that, and to allow the tests to function in the same way, the simplest thing to do is to stringify the keys manually avoid the error for now. This is against the convention (most Rails devs prefer symbols), but this allows the tests to remain as they were. (transferred from ManageIQ/manageiq@4e96ee4)
In the following: rails/rails#25146 Rails added a regression to making nested joins with references to those joins in the WHERE clause, and this causes an error when running this test suite in Rails 5.0.1. This has been addressed in Rails with: rails/rails#27598 And has been merged into master, but it is likely that Rails 5.0.1 will not be pulled from Rubygems, and the ManageIQ will fail to run tests properly with that version of Rails. Because of that, and to allow the tests to function in the same way, the simplest thing to do is to stringify the keys manually avoid the error for now. This is against the convention (most Rails devs prefer symbols), but this allows the tests to remain as they were. (transferred from ManageIQ/manageiq@4e96ee4)
Fixes #25128