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

use column transformer for EXCLUDED column name on upsert query of PostgreSQL #886

Merged

Conversation

Yoshiaki-Harada
Copy link
Contributor

Requery does not currently use the column transformer when generating EXCLUDED column name in Postgres.

Therefore, when specifying a column transformer that makes the column name a snake case, Requery generate a SQL as bellow:

insert into test (id, message_title) values (?, ?) on conflict (id) do update set id = EXCLUDED.id, message_title = EXCLUDED.messageTitle

This query does not work well because the column name used in EXCLUDED clause wasn’t converted correctly (it must be a ‘message_title’, but is a ‘messageTitle’).

In my patch, I changed a UpsertOnConflictDoUpdate class to use a column transformer when generating EXCLUDED column names, so it generates a SQL as bellow:

insert into test (id, message_title) values (?, ?) on conflict (id) do update set id = EXCLUDED.id, message_title = EXCLUDED.message_title  

@CLAassistant
Copy link

CLAassistant commented Jul 25, 2019

CLA assistant check
All committers have signed the CLA.

@npurushe npurushe merged commit 64bd289 into requery:master Aug 2, 2019
@npurushe
Copy link
Contributor

npurushe commented Aug 2, 2019

Thanks !change looks good, will include this in the next dot update

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.

3 participants