-
Notifications
You must be signed in to change notification settings - Fork 566
Rails 6.1: Fix 'TypeError: can't quote ActiveRecord::Relation::QueryAttribute' #883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 6.1: Fix 'TypeError: can't quote ActiveRecord::Relation::QueryAttribute' #883
Conversation
took the idea from rails/rails@157f6a6#diff-39e2986a9d501a5ce3587a8d5944feb67c91e777f44270627850c219709d6510 and the fact that SubstituteCollector is only used for unprepared_statements (see https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L729)
Can you please add a changelog entry for this one? |
@mgrunberg I have a cleaner fix for this issue in #885. Could you review and see what you think? |
@aidanharan I evaluated adding Rails deprecated passing ActiveRecord objects to quote (rails/rails@87886c9). I consider passing ActiveModel::Attributes as something similar to the deprecated behavior. The fact that we call Also, allowing quoting of Digging in Rails code (this time main branch) I keep finding places where they decide not to quote What do you think? |
@mgrunberg Yeah I think your fix is better. I've created #896 to revert #885 so that this PR can be used instead. |
Hey, can you resolve the changelog conflict so I can merge it? |
@wpolicarpo done |
…-sqlserver#896) Co-authored-by: Aidan Haran <aharan@fusioneer.com>
…ttribute' (rails-sqlserver#883) * don't patch unprepared statements took the idea from rails/rails@157f6a6#diff-39e2986a9d501a5ce3587a8d5944feb67c91e777f44270627850c219709d6510 and the fact that SubstituteCollector is only used for unprepared_statements (see https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L729) * handle explain with ::ActiveRecord::Relation::QueryAttribute binds Idea took from rails/rails@157f6a6#diff-137c2c919e7860732301c49c60a700517455564bf463ff036756fb31c02a60e5 * add changelog entry * apply suggestion
There are some test failing due to
TypeError: can't quote ActiveRecord::Relation::QueryAttribute
.I found two places where this was happening:
visit_Arel_Nodes_HomogeneousIn
is bindingActiveRecord::Relation::QueryAttribute
even for unprepared statements (.i.ePost.where(author: [1, 2]).to_sql
). Unprepared statement usesArel::Collectors::SubstituteBinds
which quote the binded value (see abstract_adapter to confirm what I'm saying)::ActiveModel::Attribute
(not only byvisit_Arel_Nodes_HomogeneousIn
hack).