Open katafrakt opened 8 months ago
Oh, I just realized that it works when I specify WriteType
as write
# not: attribute :value, WriteType, read: ReadType
attribute :value, write: WriteType, read: ReadType
Not sure why I missed this before. It makes sense.
Actually, that was premature optimism. With write:
is does not encode the value before putting it in the db, so naturally in this case it does not crash, but it also does not do what's desired - there's just a plain string "test value" in the database.
Describe the bug
When using custom write type and read type to modify the data before inserting / after fetching data from the database, the
create
command passes original unmodified data to read type, sometimes causing exceptions.To Reproduce
This causes:
The data is actually written correctly to the database, but it fails on trying to return the value. Stacktrace points to
finalize
hook of rom-sql:This indeed tries to feed original data, unmodified by write type, to a read type.
Expected behavior
Creating a record using custom write and read type returns correct result.
My environment