Skip to content

Commit e5092df

Browse files
committed
Don't know what these are for
1 parent fae4540 commit e5092df

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def release_savepoint(name = current_savepoint_name)
7777

7878
def case_sensitive_comparison(table, attribute, column, value)
7979
if column.collation && !column.case_sensitive?
80-
table[attribute].eq(Arel::Nodes::Bin.new(Arel::Nodes::BindParam.new))
80+
table[attribute].eq(Arel::Nodes::Bin.new(value))
8181
else
8282
super
8383
end
@@ -270,7 +270,7 @@ def sp_executesql_types_and_parameters(binds)
270270

271271
def sp_executesql_sql_type(attr)
272272
return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
273-
case value = attr.value_for_database
273+
case value = attr.try(:value_for_database) || attr.try(:value_before_type_cast)
274274
when Numeric
275275
value > 2_147_483_647 ? 'bigint'.freeze : 'int'.freeze
276276
else
@@ -279,12 +279,17 @@ def sp_executesql_sql_type(attr)
279279
end
280280

281281
def sp_executesql_sql_param(attr)
282-
case attr.value_for_database
282+
value = attr.try(:value_for_database) || attr.try(:value_before_type_cast)
283+
if value.is_a?(ActiveRecord::StatementCache::Substitute)
284+
return quote('')
285+
end
286+
287+
case value
283288
when Type::Binary::Data,
284289
ActiveRecord::Type::SQLServer::Data
285-
quote(attr.value_for_database)
290+
quote(value)
286291
else
287-
quote(type_cast(attr.value_for_database))
292+
quote(type_cast(value))
288293
end
289294
end
290295

0 commit comments

Comments
 (0)