File tree 1 file changed +11
-6
lines changed
lib/active_record/connection_adapters/sqlserver
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -331,11 +331,7 @@ def sp_executesql_types_and_parameters(binds)
331
331
def sp_executesql_sql_type ( attr )
332
332
return attr . type . sqlserver_type if attr . respond_to? ( :type ) && attr . type . respond_to? ( :sqlserver_type )
333
333
334
- value = if attr . is_a? ( Symbol ) || attr . is_a? ( String ) || attr . is_a? ( Numeric )
335
- attr
336
- else
337
- attr . value_for_database
338
- end
334
+ value = basic_attribute_type? ( attr ) ? attr : attr . value_for_database
339
335
340
336
if value . is_a? ( Numeric )
341
337
value > 2_147_483_647 ? "bigint" . freeze : "int" . freeze
@@ -345,7 +341,7 @@ def sp_executesql_sql_type(attr)
345
341
end
346
342
347
343
def sp_executesql_sql_param ( attr )
348
- return quote ( attr ) if attr . is_a? ( Symbol ) || attr . is_a? ( String ) || attr . is_a? ( Numeric )
344
+ return quote ( attr ) if basic_attribute_type? ( attr )
349
345
350
346
case value = attr . value_for_database
351
347
when Type ::Binary ::Data , ActiveRecord ::Type ::SQLServer ::Data
@@ -355,6 +351,15 @@ def sp_executesql_sql_param(attr)
355
351
end
356
352
end
357
353
354
+ def basic_attribute_type? ( type )
355
+ type . is_a? ( Symbol ) ||
356
+ type . is_a? ( String ) ||
357
+ type . is_a? ( Numeric ) ||
358
+ type . is_a? ( Time ) ||
359
+ type . is_a? ( TrueClass ) ||
360
+ type . is_a? ( FalseClass )
361
+ end
362
+
358
363
def sp_executesql_sql ( sql , types , params , name )
359
364
if name == "EXPLAIN"
360
365
params . each . with_index do |param , index |
You can’t perform that action at this time.
0 commit comments