Skip to content

Incorrect return type for ActiveRecord encrypted hashes #2631

@olivier-thatch

Description

@olivier-thatch

Bit of an edge case, but:

class MyModel < ApplicationRecord
  serialize :secret_hash, type:Hash, coder: JSON
  encrypts :secret_hash
end

results in the following signatures:

class MyModel
    sig { returns(::String) }
    def secret_hash; end

    sig { params(value: ::String).returns(::String) }
    def secret_hash=(value); end
end

which makes sense since secret_hash is a string in the DB schema (due to being encrypted), but the type for the accessors should be T::Hash[T.untyped, T.untyped].

I can take a stab at a PR if this is something that would be accepted into Tapioca.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions