Changeset 3463
- Timestamp:
- 01/22/06 09:34:41 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/test/finder_test.rb (modified) (2 diffs)
- trunk/activerecord/test/fixtures/accounts.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r3460 r3463 1 1 *SVN* 2 3 * Make dynamic finders honor additional passed in :conditions. #3569 [Oleg Pudeyev <pudeyo@rpi.edu>, Marcel Molina Jr.] 2 4 3 5 * Show a meaningful error when the DB2 adapter cannot be loaded due to missing dependencies. [Nicholas Seckar] trunk/activerecord/lib/active_record/base.rb
r3439 r3463 991 991 conditions = construct_conditions_from_arguments(attribute_names, arguments) 992 992 993 if arguments[attribute_names.length].is_a?(Hash) 994 find(finder, { :conditions => conditions }.update(arguments[attribute_names.length])) 993 if (extra_options = arguments[attribute_names.size]).is_a?(Hash) 994 finder_options = extra_options.merge(:conditions => conditions) 995 if extra_options[:conditions] 996 with_scope(:find => {:conditions => extra_options[:conditions]}) do 997 find(finder, finder_options) 998 end 999 else 1000 find(finder, finder_options) 1001 end 995 1002 else 996 1003 send("find_#{finder}", conditions, *arguments[attribute_names.length..-1]) # deprecated API trunk/activerecord/test/finder_test.rb
r3382 r3463 7 7 8 8 class FinderTest < Test::Unit::TestCase 9 fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts 9 fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :accounts 10 10 11 11 def test_find … … 201 201 end 202 202 203 def test_find_by_one_attribute_with_order_option 204 assert_equal accounts(:signals37), Account.find_by_credit_limit(50) 205 assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC') 206 end 207 208 def test_find_by_one_attribute_with_conditions 209 assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) 210 end 211 212 def test_find_by_one_attribute_with_several_options 213 assert_equal accounts(:unknown), Account.find_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) 214 end 215 203 216 def test_find_by_one_missing_attribute 204 217 assert_raises(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } trunk/activerecord/test/fixtures/accounts.yml
r2595 r3463 12 12 firm_id: 6 13 13 credit_limit: 50 14 15 last_account: 16 id: 4 17 firm_id: 2 18 credit_limit: 60