Skip to content

Commit

Permalink
Fix serialized encrypted attributes (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan authored Sep 2, 2024
1 parent b59f40d commit 2a60a21
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ def sp_executesql_types_and_parameters(binds)

def sp_executesql_sql_type(attr)
if attr.respond_to?(:type)
return attr.type.sqlserver_type if attr.type.respond_to?(:sqlserver_type)
type = attr.type.is_a?(ActiveRecord::Normalization::NormalizedValueType) ? attr.type.cast_type : attr.type
type = type.subtype if type.serialized?

if attr.type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) && attr.type.instance_variable_get(:@cast_type).respond_to?(:sqlserver_type)
return attr.type.instance_variable_get(:@cast_type).sqlserver_type
return type.sqlserver_type if type.respond_to?(:sqlserver_type)

if type.is_a?(ActiveRecord::Encryption::EncryptedAttributeType) && type.instance_variable_get(:@cast_type).respond_to?(:sqlserver_type)
return type.instance_variable_get(:@cast_type).sqlserver_type
end
end

Expand Down

0 comments on commit 2a60a21

Please sign in to comment.