Skip to content

Fix serialized encrypted attributes #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading