-
Notifications
You must be signed in to change notification settings - Fork 212
Polymorphism broken with Rails 4.2 #369
Comments
Hello @rogierslag, |
It happens both in 4.2.1 as well as 4.2 itself The error is in fact
which is weird, since the entire SQL query is invalid. I do have tests, but no minimum example, our tests which fails on this kinda travels through the entire application |
Apologies, I deleted my last reply. For some reason, I thought this was the Ransack issue tracker instead of the Squeel one. Sorry, it's late here ;) |
Still, I'll try to see if I can create a minimum tests which succeeds in 4.1.x and fails in 4.2.x ;) |
That would be great. This could be an issue in Polyamorous too. cc @bigxiang |
Running into the same issue :( It is working with Rails 4.1.10, but fails with 4.2.1 |
Ill try to create a testcase tomorrow (Europe/Amsterdam region). Cant assign it to myself so please ping me if I havent reported back by the end of the week! |
@rogierslag ping :) |
I'm currently compiling a test case. It is taking quite some time though since I need to take a copy of the api, and strip it down extensively before we can allow it to be opensourced oops: Forgot to press comment. Anyway, I finished and a test case is located over here https://github.com/inventid/squeel-bug-369-testcase |
Some explanaiton: by company policy the project has a The box ships with Rails 4.2.1, in you downgrade Rails in the Vagrantfile to 4.1.7 (and do |
And finally, Rails versions 4.1.10 does not have the problem. That might further reduce the number of things you will have to check |
And progress on this one? |
@rogierslag If so, you would have seen it here. Someone who is experiencing this issue will be most likely to work on it. For others, it's a free time thing. |
I've been debugging for some time now, and it seems the problem boils down to the following. The scopes by pundit are actually handled nice, and the value is in the set. When callign This is caused since the query is changed in the form The specific method is I'll try to recreate the specific test case without pundit and other libraries, and provide seeds and tests as well |
I have recreated the test case, this time is should help you much better. Just start the vagrant machine, follow the instructions after the machine is up (effectively installing the gems and running The code is still located at https://github.com/inventid/squeel-bug-369-testcase @joostverdoorn for info |
Rails 4.2.4 did not fix the bug. Test result are located here https://travis-ci.org/inventid/squeel-bug-369-testcase/builds/77837020 |
I have found the main problem (at least for this I think). We load the specific table multiple times, but each time the polymorphous relation is set to another table. Squeel seems unable to handle this. We have "fixed" the problem by using a |
I'm trying to migrate an app to Rails 4.2 but I see a weird bug where A:Relation binding values are in the wrong order when compiled. (Doesn't Squeel need fixing instead of Rails in this case?) SQL Differences# r4.2.6 w/ Squeel - Wrong (Note that the container_type inherited from the carrier_id value and dest_place_id from the container_type, etc...)
SELECT `charges`.* FROM `charges` INNER JOIN `shipments` ON `shipments`.`id` = `charges`.`shipment_id` LEFT OUTER JOIN `shipment_bookings` ON `shipment_bookings`.`id` = `shipments`.`shipment_booking_id`
WHERE `charges`.`type` IN ('ShipmentCharge') AND `shipment_bookings`.`etd` > '2013-06-20' AND `charges`.`container_type` = 1 AND (`shipment_bookings`.`carrier_id` = 20 AND `shipment_bookings`.`orig_place_id` = 2 AND `shipment_bookings`.`dest_place_id` = 0)
# r4.1.15 w/ Squeel - Correct
SELECT `charges`.* FROM `charges` INNER JOIN `shipments` ON `shipments`.`id` = `charges`.`shipment_id` LEFT OUTER JOIN `shipment_bookings` ON `shipment_bookings`.`id` = `shipments`.`shipment_booking_id`
WHERE `charges`.`type` IN ('ShipmentCharge') AND `shipment_bookings`.`etd` > '2013-06-20' AND `charges`.`container_type` = 0 AND ((`shipment_bookings`.`carrier_id` = 1 AND `shipment_bookings`.`orig_place_id` = 20 AND `shipment_bookings`.`dest_place_id` = 2))
# r4.2.6/r4.1.15 w/o Squeel - Correct
SELECT `charges`.* FROM `charges` INNER JOIN `shipments` ON `shipments`.`id` = `charges`.`shipment_id` LEFT OUTER JOIN `shipment_bookings` ON `shipment_bookings`.`id` = `shipments`.`shipment_booking_id`
WHERE `charges`.`type` IN ('ShipmentCharge') AND `shipment_bookings`.`carrier_id` = 1 AND `shipment_bookings`.`orig_place_id` = 20 AND `shipment_bookings`.`dest_place_id` = 2 AND (`shipment_bookings`.`etd` > '2013-06-20') AND `charges`.`container_type` = 0 |
…rphic joins erros in squeel (activerecord-hackery#369 and activerecord-hackery#380).
We have the following scenario. A user can have access to a shop. This is done with an polymorphic
AccessRight
class (accessible_type = 'Shop'
). However, it seems on Rails 4.2 Squeel can no longer figure out what the type should beThe scope looks like this
As you can see, one time the
accessible_type
isnt set at all, resulting in invalid SQLIn Rails 4.1, we simply did
@joostverdoorn for info
The text was updated successfully, but these errors were encountered: