Importing an empty array of objects/values should be supported

This commit is contained in:
Franck Verrot 2011-03-14 09:56:51 +01:00 committed by Zach Dennis
parent 2517770a38
commit d901a7c60f
2 changed files with 10 additions and 0 deletions

View file

@ -178,6 +178,9 @@ class ActiveRecord::Base
end
# end
end
# supports empty array
elsif args.last.is_a?( Array ) and args.last.empty?
return ActiveRecord::Import::Result.new([], 0) if args.last.empty?
# supports 2-element array and array
elsif args.size == 2 and args.first.is_a?( Array ) and args.last.is_a?( Array )
column_names, array_of_attributes = args