Incorrect return type for ActiveRecord encrypted hashes
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MyModel example and inspecting the generated RBI signatures for the encrypted serialized hash. Trace how Tapioca derives accessor types from serialize and encrypts; done when both accessors use T::Hash[T.untyped, T.untyped] and the relevant behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100