Skip to content

Commit 5a52d49

Browse files
committed
Fix SerializedAttribute tests
1 parent cc86d04 commit 5a52d49

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ def sp_executesql(sql, name, binds, options = {})
254254
def sp_executesql_types_and_parameters(binds)
255255
types, params = [], []
256256
binds.each_with_index do |attr, index|
257-
if attr.is_a?(Arel::Nodes::BindParam)
258-
attr = attr.value
259-
end
257+
attr = attr.value if attr.is_a?(Arel::Nodes::BindParam)
260258

261259
types << "@#{index} #{sp_executesql_sql_type(attr)}"
262260
params << sp_executesql_sql_param(attr)
@@ -266,7 +264,7 @@ def sp_executesql_types_and_parameters(binds)
266264

267265
def sp_executesql_sql_type(attr)
268266
return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
269-
case value = attr.try(:value_for_database) || attr.try(:value_before_type_cast)
267+
case value = attr.value_for_database
270268
when Numeric
271269
value > 2_147_483_647 ? 'bigint'.freeze : 'int'.freeze
272270
else
@@ -275,9 +273,7 @@ def sp_executesql_sql_type(attr)
275273
end
276274

277275
def sp_executesql_sql_param(attr)
278-
value = attr.try(:value_for_database) || attr.try(:value_before_type_cast)
279-
280-
case value
276+
case value = attr.value_for_database
281277
when Type::Binary::Data,
282278
ActiveRecord::Type::SQLServer::Data
283279
quote(value)

0 commit comments

Comments
 (0)