rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.08k stars 161 forks source link

Remove implicit convertion in update changeset #587

Closed flash-gordon closed 4 years ago

flash-gordon commented 4 years ago

As of now, when tuples are compared in the update changeset, original may be a struct when the relation is used in a repo: https://github.com/rom-rb/rom/blob/212ccab204c49b64f8d81e03b6b3dc7c041d1182/changeset/lib/rom/changeset/update.rb#L68 This leads to implicit coercion to a hash. Since we plan to remove Struct#to_hash in dry-struct 2.0, it'll bring incompatibility. Fortunately, something as simple as

def original
  @original ||= relation.with(auto_struct: false).one
end

may do the trick.