Skip to content

Commit f844fa5

Browse files
committed
Support encrypting binary columns
1 parent b19c728 commit f844fa5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,13 @@ def sp_executesql_types_and_parameters(binds)
328328
end
329329

330330
def sp_executesql_sql_type(attr)
331-
return attr.type.sqlserver_type if attr.respond_to?(:type) && attr.type.respond_to?(:sqlserver_type)
331+
if attr.respond_to?(:type)
332+
return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
333+
334+
if attr.type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) && attr.type.instance_variable_get(:@cast_type).respond_to?(:sqlserver_type)
335+
return attr.type.instance_variable_get(:@cast_type).sqlserver_type
336+
end
337+
end
332338

333339
value = basic_attribute_type?(attr) ? attr : attr.value_for_database
334340

0 commit comments

Comments
 (0)