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

Closed
carolyncole opened this Issue May 14, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@carolyncole
Copy link
Contributor

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
end

resource = Resource.new(title: "bla")
resource.title # => "bla"
output = persister.save(resource: resource) # NO exception thrown.
output.title = "bla"
@tpendragon

This comment has been minimized.

Copy link
Collaborator

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: https://github.com/pulibrary/figgy/blob/master/app/change_sets/scanned_resource_change_set.rb#L9. 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.