Fix inconsistent behaviour across adapters with read types and "create" command #432
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofrelation.where
in default implementation ofinsert
method ofCreate
command.relation.where
already applies the read types on materialization, whilerelation.dataset.where
does not. This is also consistent with howUpdate
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.