I'd like to remove all existing constraints from an ActiveRecord::Relation and leave the rest in-tact.
I am NOT looking for #unscoped since I would like to keep any joins/order clauses around.
Additionally, I would like to re-use the constraints that were removed in another query, so the ability to call #to_sql on them would be a very nice bonus.
This is the best I've been able to hack together:
Order.where(id: 1).where(id: 2).arel.constraints.to_sql
=> "`orders`.`id` = 1 AND `orders`.`id` = 2"
...but that just seems wrong. As far as I can tell #constraints always has one item in it, but I don't know that will always be true.