Skip to content
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

Search fails in certain edge case with SQL error #1190

Closed
gouthamvel opened this issue Jul 13, 2018 · 1 comment
Closed

Search fails in certain edge case with SQL error #1190

gouthamvel opened this issue Jul 13, 2018 · 1 comment
Labels
bug breakages in functionality that is implemented search finding things through our models

Comments

@gouthamvel
Copy link

This issue might be relating to #1179

Issue

Search gives a SQL error when searching in multiple association attributes linking to same foreign table.
Order (table: orders)
| -> Customer (table: customers)
| -> Seller (table: customers)

How to reproduce

clone this gouthamvel@45bc418 and run test.

Note

I'm not sure if this is a issue with administrate or ActiveRecord. If you cloned my patch then
cd spec/example_app/ && bundle exec rails c then run

Order.joins(:customer, :seller).includes(:customer, :seller).first - This works fine Order.joins(:customer, :seller).includes(:seller, :customer).first - This won't

Quick fix for anyone having this issue.

Change the order in which you define the ATTRIBUTE_TYPES or COLLECTION_ATTRIBUTES, this will in turn change the order in query and the issue should disappear.

@nickcharlton nickcharlton added bug breakages in functionality that is implemented search finding things through our models labels Jan 2, 2020
@nickcharlton
Copy link
Member

It seems like this one fell aside. I'm going to close this as it's been a long time, but please reopen if you're still facing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug breakages in functionality that is implemented search finding things through our models
Projects
None yet
Development

No branches or pull requests

2 participants