-
-
Notifications
You must be signed in to change notification settings - Fork 804
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
Incorrect references to table aliases in Rails 6.1 #1217
Comments
FYI I think that this may be to do with this issue in Rails rails/rails#41498 Which links to this commit where the claim is made that an attempt to de-duplicate JOINS was made in an effort to fix eager loading: rails/rails@10b36e8 |
Here is a patch that might leave eager loading a little broken but does fix all of our joining issues. ActiveRecord has identified rails/rails#41498 as a bug so hopefully they will fix the issue in Rails. The issue is they incorrectly de-duplicate OUTER JOINS.
|
This simply mirrors ActiveRecord's "deduplication" of joined tables, to not use table aliases that are not actually in the final query's JOIN clause.
I encountered the same issue and came up with a "solution" that keeps the fix for eager loading in place: #1447 |
This simply mirrors ActiveRecord's "deduplication" of joined tables, to not use table aliases that are not actually in the final query's JOIN clause.
Fixed by #1447! |
I've gotta start this with thanks so much for Ransack, really the only time it ever gets in the way are during Rails upgrades 😄
I've seen other issues like the one I'm reporting (#1182, #1153, #1144) but they're on Rails 6.0 or have been fixed in the Rails 6.0 stable branch that will probably be released as Rails 6.0.4. We are upgrading to Rails 6.1 and am hitting table alias issues as part of that.
gem 'rails', github: 'rails/rails', branch: '6-0-stable'
then the below example will work.gem 'rails', github: 'rails/rails', branch: '6-1-stable'
then the first 2 assertions work and the last 2 generate a where clause using a table alias that does not exist.In general the error raised is
As the table
user_applications_activities
does not exist in the gathering part of the query.The only difference between the first 3 assertions and the last 3 are the ordering of the search models & attributes (
user_name_or_user_application_name
vsuser_application_name_or_user_name
).I added another has relationship (to
somethings
) and started to query on that and it appears that it doesn't break the SQL as badly if that information helps debugging 🤷The text was updated successfully, but these errors were encountered: