diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-05 13:22:24 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-05 13:22:24 -0300 |
commit | 69a379242e653f1f1e6968c3f0905d841145ae61 (patch) | |
tree | dbf5652edefbfa60bb8cfc64f40ddf2aec3dc69e | |
parent | a8d85c4d518e8ed73ac8a5685bfb2a2a842900fd (diff) | |
parent | 7e20bdc20dd91e1195086a5f54178a01b74ebb31 (diff) | |
download | rails-69a379242e653f1f1e6968c3f0905d841145ae61.tar.gz rails-69a379242e653f1f1e6968c3f0905d841145ae61.tar.bz2 rails-69a379242e653f1f1e6968c3f0905d841145ae61.zip |
Merge pull request #14978 from bogdan/relation-join
[Regression 4.0 -> 4.1] Put back Relation#join method as a delegate to Array
-rw-r--r-- | activerecord/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/delegation.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/comment.rb | 4 |
5 files changed, 17 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index e51b5b44cc..f78b68a4f3 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,10 @@ +* Revert the behaviour of AR::Relation#join changed through 4.0 => 4.1 to 4.0 + + In 4.1.0 Relation#join is delegated to Arel#SelectManager. + In 4.0 series it is delegated to Array#join + + *Bogdan Gusiev* + * Log nil binary column values correctly. When an object with a binary column is updated with a nil value diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index 9c666dcd3b..50f4d5c7ab 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -43,7 +43,7 @@ module ActiveRecord :keep_if, :pop, :shift, :delete_at, :compact, :select! ].to_set # :nodoc: - delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to_ary, to: :to_a + delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to_ary, :join, to: :to_a delegate :table_name, :quoted_table_name, :primary_key, :quoted_primary_key, :connection, :columns_hash, :to => :klass diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index 9b2bfed039..29c9d0e2af 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -32,7 +32,7 @@ module ActiveRecord :exclude?, :find_all, :flat_map, :group_by, :include?, :length, :map, :none?, :one?, :partition, :reject, :reverse, :sample, :second, :sort, :sort_by, :third, - :to_ary, :to_set, :to_xml, :to_yaml + :to_ary, :to_set, :to_xml, :to_yaml, :join ] ARRAY_DELEGATES.each do |method| diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 68e62934c1..6a880c6680 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1677,4 +1677,8 @@ class RelationTest < ActiveRecord::TestCase merged = left.merge(right) assert_equal post, merged.first end + + def test_relation_join_method + assert_equal 'Thank you for the welcome,Thank you again for the welcome', Post.first.comments.join(",") + end end diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index ede5fbd0c6..f82df417ce 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -26,6 +26,10 @@ class Comment < ActiveRecord::Base all end scope :all_as_scope, -> { all } + + def to_s + body + end end class SpecialComment < Comment |