zio-quill icon indicating copy to clipboard operation
zio-quill copied to clipboard

Support embedded fields in OnConflict for MySQL

Open mgibowski opened this issue 4 years ago • 1 comments

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

mgibowski avatar Dec 13 '20 18:12 mgibowski

CLA assistant check
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.

CLAassistant avatar Jan 24 '22 22:01 CLAassistant

@mgibowski Can you rebase your PR, please?

guizmaii avatar Oct 19 '23 12:10 guizmaii