orm
orm copied to clipboard
🐛 Query builder `load` for bytea relations fails with exception
No duplicates 🥲.
- [X] I have searched for a similar issue in our bug tracker and didn't find any solutions.
What happened?
When an entity has a RefersTo
relation with bytea key (wrapped in a ValueInterface
), querying it with load
will result in cycle crashing with the following exception:
[Cycle\Database\Exception\StatementException]
SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0xf0 0x1f 0xc9 0x6a
Lazy loading a single relation works fine.
Version
ORM 2.0.1
PHP 8.0
Found the reason why this happening: https://github.com/cycle/database/blob/11cf9d606092b87dd0a2566021ec729abaa3713c/src/Driver/Driver.php#L488.
When the driver binds the parameter, it uses the binary value as is, which is string.
This could be resolved if we first wrap the value to its corresponding ValueInterface according to the column typecast, where we handle the rawType
.
I will try to add a repro case later this week.