Migration from squeel
Closed this issue · 3 comments
brunobrgs commented
# Using squeel
City.where { state_id.in(State.all) }.to_sql
=> "SELECT `cities`.* FROM `cities` WHERE `cities`.`state_id` IN (SELECT `states`.`id` FROM `states`)"
# Using baby_squeel
City.where { state_id.in(State.all) }.to_sql
=> "SELECT `cities`.* FROM `cities` WHERE `cities`.`state_id` IN (SELECT `states`.* FROM `states`)"
I have this kind of problem spread throughout my application, i am migrating and also using the compatibility mode
.
Is there a way to get this same behavior back?
rzane commented
The easy solution is to just say state_id.in(State.select(:id))
.
I understand why you'd expect this to be the default implicit behavior, but consider the possibility where you might actually want to say:
City.where { state_id.in(State.select(:some_other_id)) }
brunobrgs commented
Yes, thanks
I was just imagining if there was not a way to just keep it working in the old way.
With this change, i will need to change a lot of places.
rzane commented
Yeah, sorry :(