ransack icon indicating copy to clipboard operation
ransack copied to clipboard

Joining a table twice in a search

Open tomraulet opened this issue 7 years ago • 1 comments

Hi there,

I'm using your amazing ransack gem inside my app, but I'm experiencing a weird behavior. I recently began to upgrade to rails 4.1.16 from 4.0.3 (and later to 4.2 and 5). (Same behavior from rails 4.1.16 to rails 5.1.4)

Unfortunately there is a regression for me, here is the gist I made for you, accroding to your contribution guide : https://gist.github.com/foxpowa/7e84f7a43d1677af5652bd037aa4b2fd

Basically, my query implies to join the same table (parameters) twice. The last join (parameter_definitions) is a subset selection for previously joined parameters data.

Previously, ransack was generating the query in the assert, with the alias 'parameters_parameter_groups'. But now, as you guess, it tries to join the 'parameter_definition' on the first 'parameters' join.

Is there something I missed ?

My apologies if there already is some posts about this issue somewhere in web, I was unable to find it.

Let me know if you want other informations.

tomraulet avatar Jan 22 '18 15:01 tomraulet

Thank you @foxpowa for the gist, will look at this when I have time.

scarroll32 avatar Feb 28 '18 19:02 scarroll32

Gist is deleted, closing.

scarroll32 avatar Oct 24 '23 20:10 scarroll32