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

Store Single values #438

carolyncole opened this Issue May 14, 2018 · 1 comment


None yet
2 participants
Copy link

commented May 14, 2018

Our current models store many items as single values. With Valkyrie 1.0 you may no longer store single values, but this does not make much sense for the rest of the system.

We have worked around this by disabling the multiple check, since our system works just fine. See PR for code: psu-libraries/cho#520.

A longer term solution might be to store singular values like we store other non supported types (Dates, boolean).

Success criteria:

class Resource < Valkyrie::Resource
  attribute :title, Valkyrie::Types::String

resource = "bla")
resource.title # => "bla"
output = resource) # NO exception thrown.
output.title = "bla"

This comment has been minimized.

Copy link

commented May 14, 2018

but this does not make much sense for the rest of the system.

Can you expand on why storing single values in the database is important in your use case? I was hoping this wasn't a super onerous restriction because it turned out to be quick in Figgy - I'm sorry to see it was such a problem. :(

For us we ended up just storing things as an array in the database (and model) all the time. Valkyrie::Types::Set takes care of casting single values to arrays, and our ChangeSet takes care of casting things to single values for forms and such. IE: The big motivation here was some of the adapters have a tough time storing single values, and it doesn't require a data migration to decide that a multiple valued field should be singular, but the inverse does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.