zio-quill
zio-quill copied to clipboard
Support embedded fields in OnConflict for MySQL
Fixes #1907
Problem
MySQL dialect generates wrong SQL for embedded properties in onConflictUpdate
. Correct SQL fragment would be: field = VALUES(field)
and currently it is field = field
.
Solution
I have extended pattern matching in conflict tokenizer to support nested excluded property and added corresponding test to MySQLDialectSpec
.
Notes
- This solution supports only one level of nesting embedded classes. Is it enough for real-world use cases? If not, one could add more cases in the pattern matching clause.
- I checked implementations of other dialects supporting
OnConflict
(Postgres and Sqlite) and they both work fine. If necessary, I could add passing tests that verify that.
Checklist
- [x] Unit test all changes
- [x] Update
README.md
if applicable - [x] Add
[WIP]
to the pull request title if it's work in progress - [x] Squash commits that aren't meaningful changes
- [x] Run
sbt scalariformFormat test:scalariformFormat
to make sure that the source files are formatted
@getquill/maintainers
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
@mgibowski Can you rebase your PR, please?