File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,8 @@ def column_types
163
163
@types_hash ||= begin
164
164
types = { }
165
165
@columns . each_with_index do |name , index |
166
- types [ name ] = types [ index ] = @column_types [ index ]
166
+ type = @column_types [ index ] || Type . default_value
167
+ types [ name ] = types [ index ] = type
167
168
end
168
169
types . freeze
169
170
end
Original file line number Diff line number Diff line change @@ -147,5 +147,21 @@ def result
147
147
assert_equal a . rows , b . rows
148
148
assert_equal a . column_indexes , b . column_indexes
149
149
end
150
+
151
+ test "column_types handles nil types in the column_types array" do
152
+ values = [ [ "1.1" , "2.2" ] , [ "3.3" , "4.4" ] ]
153
+ columns = [ "col1" , "col2" ]
154
+ types = [ Type ::Integer . new , nil ] # Deliberately nil type for col2
155
+ result = Result . new ( columns , values , types )
156
+
157
+ assert_not_nil result . column_types [ "col1" ]
158
+ assert_not_nil result . column_types [ "col2" ]
159
+
160
+ assert_instance_of ActiveRecord ::Type ::Value , result . column_types [ "col2" ]
161
+
162
+ assert_nothing_raised do
163
+ result . column_types [ "col2" ] . deserialize ( "test value" )
164
+ end
165
+ end
150
166
end
151
167
end
You can’t perform that action at this time.
0 commit comments