mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActiveRecord::Base.joins should allow single nil argument [#6181 state:resolved]
This commit is contained in:
parent
e89fff2f6b
commit
40b15f9f38
2 changed files with 5 additions and 1 deletions
|
@ -63,7 +63,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def joins(*args)
|
def joins(*args)
|
||||||
return self if args.blank?
|
return self if args.compact.blank?
|
||||||
|
|
||||||
relation = clone
|
relation = clone
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,10 @@ class RelationTest < ActiveRecord::TestCase
|
||||||
assert_equal [2, 4, 6, 8, 10], even_ids.sort
|
assert_equal [2, 4, 6, 8, 10], even_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_joins_with_nil_argument
|
||||||
|
assert_nothing_raised { DependentFirm.joins(nil).first }
|
||||||
|
end
|
||||||
|
|
||||||
def test_finding_with_hash_conditions_on_joined_table
|
def test_finding_with_hash_conditions_on_joined_table
|
||||||
firms = DependentFirm.joins(:account).where({:name => 'RailsCore', :accounts => { :credit_limit => 55..60 }}).to_a
|
firms = DependentFirm.joins(:account).where({:name => 'RailsCore', :accounts => { :credit_limit => 55..60 }}).to_a
|
||||||
assert_equal 1, firms.size
|
assert_equal 1, firms.size
|
||||||
|
|
Loading…
Reference in a new issue