Skip to content
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

Regression when redefining a store attribute with a new type #41138

Closed
georgeclaghorn opened this issue Jan 16, 2021 · 0 comments · Fixed by #41139
Closed

Regression when redefining a store attribute with a new type #41138

georgeclaghorn opened this issue Jan 16, 2021 · 0 comments · Fixed by #41139

Comments

@georgeclaghorn
Copy link
Contributor

georgeclaghorn commented Jan 16, 2021

We have a model that defines a store attribute, then redefines it with a wrapper type for encryption, like so:

class Cache < ApplicationRecord
  store :data
  encrypts :data
end

The encrypts macro boils down to:

def encrypts(name)
  attribute name, :encrypted, subtype: type_for_attribute(name)
end

After 4cc9c0f, values stored in the data attribute no longer make it to the DB:

> Cache.create! data: { trial: true }
Cache Create (0.1ms)  INSERT INTO "caches" DEFAULT VALUES

I’ve shared a minimal reproduction script as a gist.

Apologies in advance if we’re just Doing It Wrong and need to change the way we decorate attributes. I’m not familiar enough with Active Record’s attributes system to know that off the top of my head or to understand what Jonathan’s commit changed.

/cc @jonathanhefner @kamipo

kamipo added a commit to kamipo/rails that referenced this issue Jan 16, 2021
kamipo added a commit to kamipo/rails that referenced this issue Jan 16, 2021
…riginal-attribute-type"

This reverts commit 79d0c17, reversing
changes made to bc828f7.

Fixes rails#41138.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant