rom-sql
rom-sql copied to clipboard
Fix inconsistent behaviour across adapters with read types and "create" command
During the investigation for #423 I discovered that for SQLite and MySQL (or basically for everything aside from PostgreSQL) the read types are applied twice. This works well if the read type allows it, but if it does not, it fails for these adapters, making behaviour between adapter inconsistent.
The solution here is to use relation.dataset.where instead of relation.where in default implementation of insert method of Create command. relation.where already applies the read types on materialization, while relation.dataset.where does not. This is also consistent with how Update command behaves.
With that in place, we always call finalize on "raw" data from the database, avoiding double application of a read type.
The PR consists of two commits. First one just adds tests replicating the problem. The second one just changes the code.