aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-07-20 17:59:27 +0100
committerJon Leighton <j@jonathanleighton.com>2012-08-01 19:46:31 +0100
commit4efebdedf8d8b8e2be711fafb560daddb15e48ad (patch)
tree0be236a7be4e0d1685be80641c9bd9e35d24aa35 /activerecord/lib/active_record/associations
parent7f3b475608d7c0b7faadd7c1430797e91b644a35 (diff)
downloadrails-4efebdedf8d8b8e2be711fafb560daddb15e48ad.tar.gz
rails-4efebdedf8d8b8e2be711fafb560daddb15e48ad.tar.bz2
rails-4efebdedf8d8b8e2be711fafb560daddb15e48ad.zip
Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/builder/collection_association.rb11
-rw-r--r--activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb10
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb2
3 files changed, 22 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb
index af81af4ad2..dbddae0876 100644
--- a/activerecord/lib/active_record/associations/builder/collection_association.rb
+++ b/activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -1,3 +1,5 @@
+require 'active_support/deprecation'
+
module ActiveRecord::Associations::Builder
class CollectionAssociation < Association #:nodoc:
CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove]
@@ -14,6 +16,7 @@ module ActiveRecord::Associations::Builder
end
def build
+ show_deprecation_warnings
wrap_block_extension
reflection = super
CALLBACKS.each { |callback_name| define_callback(callback_name) }
@@ -24,6 +27,14 @@ module ActiveRecord::Associations::Builder
true
end
+ def show_deprecation_warnings
+ [:finder_sql, :counter_sql].each do |name|
+ if options.include? name
+ ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using scopes).")
+ end
+ end
+ end
+
private
def wrap_block_extension
diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
index 7f79ef25f2..8df28ad876 100644
--- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
+++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
@@ -14,6 +14,16 @@ module ActiveRecord::Associations::Builder
reflection
end
+ def show_deprecation_warnings
+ super
+
+ [:delete_sql, :insert_sql].each do |name|
+ if options.include? name
+ ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using has_many :through).")
+ end
+ end
+ end
+
private
def define_destroy_hook
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 14a24e02dc..b38a206bef 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -380,7 +380,7 @@ module ActiveRecord
if options[:finder_sql]
reflection.klass.find_by_sql(custom_finder_sql)
else
- scoped.all
+ scoped.to_a
end
records.each { |record| set_inverse_instance(record) }