-
Notifications
You must be signed in to change notification settings - Fork 23
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
Clarify Equality #765
Comments
One approach to this issue is to move the optimistic lock token out of That probably constitutes a major release, and might involve a bit of work since there's some use of the |
It looks like both Memory and Fedora are using the current Time of the object's instantiation to create the lock tokens: |
The other option is we just change equality to be something like AR, where if it's persisted it |
i'll express a preference for for reference: |
I'm having a hard time figuring out how we can move this forward. I think I need some use cases where I want two things to be equal to one another if they have different lock tokens. |
@tpendragon: if i recall, the motivating need here was Sets. for example, i think the behavior of the following code varies depending on otherwise irrelevant details of the adapters optimistic locking behavior: class Permission < Valkyrie::Resource
enable_optimistic_locking
attribute :mode
attribute :user
end
class ResourceWithPermissions < Valkyrie::Resource
enable_optimistic_locking
attribute :permissions, Valkyrie::Types::Set.of(Permission)
end
p = Permission.new(mode: :read, user: 'user_key')
p = Valkyrie.config.metadata_adapter.persister.save(resource: p)
resource = ResourceWithPermissions.new(permissions: [p])
p2 = Valkyrie.config.metadata_adapter.query_service.find_by(id: p.id)
resource.permissions << p2 a practical example exists in Hyrax: https://github.com/samvera/hyrax/blob/f8706bc91d1caa3a4cdd73401cc7d081ec158437/app/models/hyrax/permission.rb#L13 but honestly, i think it would be desirable as a matter of principle for |
Equality is currently based on the default
Dry::Struct
implementation, which compares allResourceClass.__attributes__
. This includes::Valkyrie::Persistence::OptimisticLockToken
, which should likely be excluded.We may want to consider excluding other reserved attributes.
The text was updated successfully, but these errors were encountered: