I’m implementing some ROM relations with the
:memory adapter and have a failing test that seems like it should work. Calling the
delete command doesn’t seem to delete tuples. Looking at the ROM tests for Memory-related commands, it seems the delete command is not in the test suite.
Could it be related to the relation criteria or how the storage is configured?
The tests are in this
ruby_event_store-rom gem. This is the command that will show 4 failing tests:
DATABASE_URL=memory:// ROM_ADAPTER=Memory make test
This project is to allow swapping multiple backing stores via a relation interface, where Memory is a drop-in replacement for SQL.
Any insights are welcome!
Please report an issue if you can confirm that it’s broken. FWIW I would love to make memory adapter truly first-class, as it can become an abstract API for other adapters, like rom-yaml/csv/git etc.
OK. That was my question, whether I should post an issue rather than a Discourse post. I’ll fork ROM and see if I can create some failing tests and PR that.
@solnic I discovered that the stored tuple is a
Hash in memory, but the tuple being deleted is a
The delete command is being called on a relation, so I understand that it would return a struct and run the command.
The solution was to call:
The reason the datastore uses hashes is because of the recommendation to use hashes when persisting. However, with this Memory datastore, it seems there needs to be a way to convert structs to hashes for comparison only.
The issue with the solution above is that the tuples returned from the delete command are now
Hashes instead of
While this solves the comparison, it technically breaks the typing of the result set (even if we are discarding it in our use case).
Is this approach in the right direction, ROM-wise?
P.S. I like changesets… is there a feature of changesets that can help address this issue of proper type comparison and then properly typed result set?