ransack icon indicating copy to clipboard operation
ransack copied to clipboard

Search on two associations where the second one is part of the default scope generates invalid SQL

Open nagyt234 opened this issue 10 years ago • 1 comments

See the minitest to demonstrate the problem: https://gist.github.com/nagyt234/b4a9bb210f7cf83262ab The generated SQL contains

AND "documents_revisions"."code" = 'BBB'

instead of

AND "documents"."code" = 'BBB'

The problem appears only if the default scope on model Revision applied and the first condition refer to an other association. Note, that this error cames up on Rails 4.1.2 (used in my project), on the newest Rails 4.2 and on Rails 5 beta either.

nagyt234 avatar Dec 23 '15 15:12 nagyt234

Issue reproduced. I messed around with it and added another test for fun here: https://gist.github.com/jonatack/1b64c924a81283e3ec83

jonatack avatar Dec 23 '15 23:12 jonatack