-
Notifications
You must be signed in to change notification settings - Fork 29
Description
In versions beyond 2.3.2 (not sure exactly which one - definitely by 2.3.8) sanitize_sql expects to be operating on a subclass of ActiveRecord::Base. The attempt to call the method directly on ActiveRecord::Base causes:
undefined method abstract_class?' for Object:Class gems/activerecord-2.3.8/lib/active_record/base.rb:2242:in
class_of_active_record_descendant'
gems/activerecord-2.3.8/lib/active_record/base.rb:1492:in base_class' gems/activerecord-2.3.8/lib/active_record/base.rb:1164:in
reset_table_name'
gems/activerecord-2.3.8/lib/active_record/base.rb:1160:in table_name' gems/activerecord-2.3.8/lib/active_record/base.rb:3154:in
quoted_table_name'
gems/ar-extensions-0.9.2/lib/ar-extensions/finders.rb:22:in `sanitize_sql'
...
This comes from:
- lib/desert/plugin_migrations/2.1/extensions/schema_statements.rb:23
insert_sql = ActiveRecord::Base.send(:sanitize_sql, [...
This is a case where calling a non-public method using .send eventually comes back to bite you. The query in question only has two values - using the connection adapter (connection.quote()) to quote the values directly would be the better solution.