Skip to content

Commit c6642a4

Browse files
pospischildiegopolido
authored andcommitted
Wrap search result in an array when there is only a single item in the results
NetSweet#82
1 parent ac92e56 commit c6642a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/netsuite/support/search_result.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def initialize(response, result_class)
2929
if response.body.has_key?(:record_list)
3030
# basic search results
3131
record_list = response.body[:record_list][:record]
32-
record_list = [record_list] if @total_records == 1
32+
record_list = [record_list] unless record_list.is_a?(Array)
3333

3434
record_list.each do |record|
3535
results << result_class.new(record)
3636
end
3737
elsif response.body.has_key? :search_row_list
3838
# advanced search results
3939
record_list = response.body[:search_row_list][:search_row]
40-
record_list = [record_list] if @total_records == 1
40+
record_list = [record_list] unless record_list.is_a?(Array)
4141

4242
record_list.each do |record|
4343
# TODO because of customFieldList we need to either make this recursive

0 commit comments

Comments
 (0)