Skip to content

Conversation

avakhov
Copy link
Contributor

@avakhov avakhov commented Mar 9, 2012

Without fix my new test failed:

  1) Failure:
test_finding_using_sql_take_into_account_only_uniq_ids(HasManyAssociationsTest) [test/cases/associations/has_many_associations_test.rb:385]:
--- expected
+++ actual
@@ -1 +1 @@
-#<Client id: 3, type: "Client", ruby_type: "Client", firm_id: 1, firm_name: nil, name: "Microsoft", client_of: 1, rating: 1, account_id: nil>
+[#<Client id: 3, type: "Client", ruby_type: "Client", firm_id: 1, firm_name: nil, name: "Microsoft", client_of: 1, rating: 1, account_id: nil>]

This only one case then logic in condition collection_association.rb#L549-555 works not good. In other cases the method returned right results:

firm.clients_using_sql.find(1, "1", 2) # => [Client1, Client2] # <- that's correct

@josevalim
Copy link
Contributor

I didn't know we assumed the fkey is an integer. But that is another discussion. Merging, thanks.

josevalim added a commit that referenced this pull request Mar 9, 2012
In AR depths use &:to_i before :uniq to process mixed arrays likes ["1", 1] correct
@josevalim josevalim merged commit 74d5d9a into rails:master Mar 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants