Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EXPOSED-226 Upsert fails with only key columns in update #1900

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

bog-walk
Copy link
Member

@bog-walk bog-walk commented Nov 26, 2023

If all columns in an upsert() block are conflict/key columns, and onUpdate is not set, an empty update clause is generated, which throws an SQLException in all databases except MySQL and MariaDB.

It is important to allow key columns in the update clause for databases that do not support insertIgnore() and must use upsert to achieve this functionality.

Including these key columns is valid SQL in all databases except Oracle, which throws ORA-38104: Columns referenced in the ON Clause cannot be updated.
So filtering the update columns now only happens if the result will not be an empty list.

If all columns in an upsert block are conflict/key columns and onUpdate is not
set, an empty update clause is generated, which throws an SQLException in all
databases except MySQL and MariaDB.

Including these key columns in the update clause is valid SQL in all databases
except Oracle, so filtering the update columns now only happens if the result
will not be an empty list.
@bog-walk bog-walk changed the title fix: EXPOSED-226 Upsert fails with all key columns in update fix: EXPOSED-226 Upsert fails with only key columns in update Nov 27, 2023
@bog-walk bog-walk marked this pull request as ready for review November 27, 2023 01:23
@bog-walk bog-walk requested review from e5l and joc-a November 27, 2023 01:52
@bog-walk bog-walk merged commit c5caebb into main Nov 27, 2023
5 checks passed
@bog-walk bog-walk deleted the bog-walk/fix-upsert-key-update branch November 27, 2023 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants