Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4783 from gregolsen/ids_reader_fix

ids_reader method fixed, test added to has_many association (for PostgreSQL)
  • Loading branch information...
commit 85c724d59e46953c52fb457411597fbab90f3a4a 1 parent 7beb5a7
@jonleighton jonleighton authored
View
2  activerecord/lib/active_record/associations/collection_association.rb
@@ -60,7 +60,7 @@ def ids_reader
end
end
- relation.uniq.pluck(column)
+ relation.pluck(column)
end
end
View
4 activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1253,6 +1253,10 @@ def test_get_ids_for_unloaded_finder_sql_associations_loads_them
assert company.clients_using_sql.loaded?
end
+ def test_get_ids_for_ordered_association
+ assert_equal [companies(:second_client).id, companies(:first_client).id], companies(:first_firm).clients_ordered_by_rating_ids
+ end
+
def test_assign_ids_ignoring_blanks
firm = Firm.create!(:name => 'Apple')
firm.client_ids = [companies(:first_client).id, nil, companies(:second_client).id, '']
View
1  activerecord/test/models/company.rb
@@ -45,6 +45,7 @@ class Firm < Company
has_many :unsorted_clients_with_symbol, :class_name => :Client
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
+ has_many :clients_ordered_by_rating, :order => "rating", :class_name => "Client"
has_many :unvalidated_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :validate => false
has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :destroy
has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all

0 comments on commit 85c724d

Please sign in to comment.
Something went wrong with that request. Please try again.