mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1471 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
361be5a7dd
commit
a9fd639adf
3 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Fixed that calling Model.find([]) returns [] and doesn't throw an exception #1379
|
||||
|
||||
* Fixed that adding a record to a has_and_belongs_to collection would always save it -- now it only saves if its a new record #1203 [Alisdair McDiarmid]
|
||||
|
||||
* Fixed saving of in-memory association structures to happen as a after_create/after_update callback instead of after_save -- that way you can add new associations in after_create/after_update callbacks without getting them saved twice
|
||||
|
|
|
@ -333,6 +333,7 @@ module ActiveRecord #:nodoc:
|
|||
when :all
|
||||
options[:include] ? find_with_associations(options) : find_by_sql(construct_finder_sql(options))
|
||||
else
|
||||
return args.first if args.first.kind_of?(Array) && args.first.empty?
|
||||
expects_array = args.first.kind_of?(Array)
|
||||
conditions = " AND #{sanitize_sql(options[:conditions])}" if options[:conditions]
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ class FinderTest < Test::Unit::TestCase
|
|||
assert_equal(topics(:second).title, Topic.find([ 2 ]).first.title)
|
||||
end
|
||||
|
||||
def test_find_an_empty_array
|
||||
assert_equal [], Topic.find([])
|
||||
end
|
||||
|
||||
def test_find_by_ids_missing_one
|
||||
assert_raises(ActiveRecord::RecordNotFound) {
|
||||
Topic.find(1, 2, 45)
|
||||
|
|
Loading…
Reference in a new issue