-
Notifications
You must be signed in to change notification settings - Fork 213
Rails 4.2.4 - Mixing attribute values #400
Comments
I just spent half an hour creating almost the exact same repro-case - I should have checked here first, but I actually thought it was an issue in activerecord itself, as I was using no squeel behavior, I was just including the gem. I really like squeel, but I have run into problems with it time and time again. This is not at all the fault of squeel, as the reasons are mainly that activerecord internals can change even in minor versions enough to break squeel (in this case going from 4.2.2 to 4.2.3). Which is also not the fault of the rails developers, these are internals after all which can change at any time. Just starting to realize that heavily patching rails internals is a game you'll eventually lose. In newer projects I've started to just use arel directly if I need anything rails doesn't provide - the syntax is not even close to squeel in terms of verbosity and readability, but it seems to survive even major rails updates without problems. |
I was trying to upgrade rails from 4.1 to 4.2 and came to this problem. # I'm using mysql 5.6
# squeel 1.2.3 with rails 4.1.14
[1] pry(main)> User.where(id: 1).where(email: '[email protected]').where(id: 1).to_sql
=> "SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 AND `users`.`email` = '[email protected]'"
# squeel 1.2.3 with rails 4.2.(0-5)
[1] pry(main)> User.where(id: 1).where(email: '[email protected]').where(id: 1).to_sql
=> "SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 AND `users`.`id` = '[email protected]' AND `users`.`email` = 1" rails/rails#21626 is surely happening, and that spec change might have broken squeel. This one's preventing me from upgrading rails to 4.2 ... |
Having the same problem on several queries where the attributes are getting mixed. |
@farrspace thanks for the fix, thats working for me 👍 |
First of all, the problem starts with a duplication on sql condition on rails 4.2, when i call the same scope twice. Following this issue rails/rails#21626
When i updated my rails to 4.2.4, the sql generated is mixing the attribute values, like script below shows:
The text was updated successfully, but these errors were encountered: