Skip to content

Commit 1a2f4dc

Browse files
committed
Fix serialized encrypted attributes
1 parent b59f40d commit 1a2f4dc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,12 @@ def sp_executesql_types_and_parameters(binds)
321321

322322
def sp_executesql_sql_type(attr)
323323
if attr.respond_to?(:type)
324-
return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
324+
type = attr.type.serialized? ? attr.type.subtype : attr.type
325325

326-
if attr.type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) && attr.type.instance_variable_get(:@cast_type).respond_to?(:sqlserver_type)
327-
return attr.type.instance_variable_get(:@cast_type).sqlserver_type
326+
return type.sqlserver_type if type.respond_to?(:sqlserver_type)
327+
328+
if type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) && type.instance_variable_get(:@cast_type).respond_to?(:sqlserver_type)
329+
return type.instance_variable_get(:@cast_type).sqlserver_type
328330
end
329331
end
330332

0 commit comments

Comments
 (0)