File tree 1 file changed +10
-7
lines changed
lib/active_record/connection_adapters/sqlserver
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -325,23 +325,26 @@ def sp_executesql_types_and_parameters(binds)
325
325
end
326
326
327
327
def sp_executesql_sql_type ( attr )
328
- return "nvarchar(max)" . freeze if attr . is_a? ( Symbol ) || attr . is_a? ( String )
329
- return attr . type . sqlserver_type if attr . type . respond_to? ( :sqlserver_type )
328
+ return attr . type . sqlserver_type if attr . respond_to? ( :type ) && attr . type . respond_to? ( :sqlserver_type )
330
329
331
- case value = attr . value_for_database
332
- when Numeric
330
+ value = if attr . is_a? ( Symbol ) || attr . is_a? ( String ) || attr . is_a? ( Numeric )
331
+ attr
332
+ else
333
+ attr . value_for_database
334
+ end
335
+
336
+ if value . is_a? ( Numeric )
333
337
value > 2_147_483_647 ? "bigint" . freeze : "int" . freeze
334
338
else
335
339
"nvarchar(max)" . freeze
336
340
end
337
341
end
338
342
339
343
def sp_executesql_sql_param ( attr )
340
- return quote ( attr ) if attr . is_a? ( Symbol ) || attr . is_a? ( String )
344
+ return quote ( attr ) if attr . is_a? ( Symbol ) || attr . is_a? ( String ) || attr . is_a? ( Numeric )
341
345
342
346
case value = attr . value_for_database
343
- when Type ::Binary ::Data ,
344
- ActiveRecord ::Type ::SQLServer ::Data
347
+ when Type ::Binary ::Data , ActiveRecord ::Type ::SQLServer ::Data
345
348
quote ( value )
346
349
else
347
350
quote ( type_cast ( value ) )
You can’t perform that action at this time.
0 commit comments