Skip to content

Incorrect return type for ActiveRecord encrypted hashes #2631

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions