From 23dfc39ed9db4591bb7b22ea6abaf7b965d1bed5 Mon Sep 17 00:00:00 2001 From: Derek Prior Date: Tue, 15 Oct 2013 13:04:58 -0400 Subject: Pluck on NullRelation accepts a list of columns `pluck` was updated to accept a list of columns, but the `NullRelation` was never updated to match that signature. As a result, calling `pluck` on a `NullRelation` results in an `ArgumentError`. --- activerecord/CHANGELOG.md | 7 +++++++ activerecord/lib/active_record/null_relation.rb | 2 +- activerecord/test/cases/relations_test.rb | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 0b7fbe5a48..f3f0aa705c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,10 @@ +* `NullRelation#pluck` takes a list of columns + + The method signature in `NullRelation` was updated to mimic that in + `Calculations`. + + *Derek Prior* + * `scope_chain` should not be mutated for other reflections. Currently `scope_chain` uses same array for building different diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 1f3d377e53..080b20134d 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -6,7 +6,7 @@ module ActiveRecord @records = [] end - def pluck(_column_name) + def pluck(*column_names) [] end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index ec43ded690..860bd424b7 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -274,7 +274,7 @@ class RelationTest < ActiveRecord::TestCase def test_none_chained_to_methods_firing_queries_straight_to_db assert_no_queries do - assert_equal [], Developer.none.pluck(:id) # => uses select_all + assert_equal [], Developer.none.pluck(:id, :name) assert_equal 0, Developer.none.delete_all assert_equal 0, Developer.none.update_all(:name => 'David') assert_equal 0, Developer.none.delete(1) -- cgit v1.2.3 From ab9475bccf1107919a255be3f5f7363f189e3621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 15 Oct 2013 17:58:03 -0300 Subject: Don't remove the select values to add they back again Conflicts: activerecord/lib/active_record/relation/finder_methods.rb --- activerecord/lib/active_record/relation/finder_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 8583286de5..fe75a32545 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -261,7 +261,7 @@ module ActiveRecord end def construct_relation_for_association_find(join_dependency) - relation = except(:select).select(join_dependency.columns + select_values) + relation = select(join_dependency.columns) apply_join_dependency(relation, join_dependency) end -- cgit v1.2.3 From 790b4011b27b4d4454c1613922887ed944aa6c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 15 Oct 2013 18:04:02 -0300 Subject: Fix typo in the changelog entry [ci skip] --- railties/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 8a0e0ff3f6..1d01c8d0e5 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,4 +1,4 @@ -* Added `--model-name` scaffld\_controller\_generator option. +* Added `--model-name` option to `ScaffoldControllerGenerator`. *yalab* -- cgit v1.2.3 From f6e7e11ad28555860bb8a1bb362fa091f48cc81a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 15 Oct 2013 14:53:50 -0700 Subject: use the cached arel table --- .../lib/active_record/associations/join_dependency/join_base.rb | 2 +- .../lib/active_record/associations/join_dependency/join_part.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/join_dependency/join_base.rb b/activerecord/lib/active_record/associations/join_dependency/join_base.rb index 48de12bcd5..adc9f63aec 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_base.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_base.rb @@ -18,7 +18,7 @@ module ActiveRecord end def table - Arel::Table.new(table_name, arel_engine) + base_klass.arel_table end def aliased_table_name diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb index d39ce94c99..e6da4d3c9e 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb @@ -19,7 +19,7 @@ module ActiveRecord # association. attr_reader :base_klass, :children - delegate :table_name, :column_names, :primary_key, :arel_engine, :to => :base_klass + delegate :table_name, :column_names, :primary_key, :to => :base_klass def initialize(base_klass, parent) @base_klass = base_klass -- cgit v1.2.3