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

upsert broken in recent persistent versions #662

Closed
rkaminsk opened this Issue Apr 7, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@rkaminsk

rkaminsk commented Apr 7, 2017

A call to upsert (Table 1 0) [TableCount +=. 1] generates an SQL query like

INSERT INTO "table" ("unique", "count") VALUES (1,0)
ON CONFLICT ("unique") DO UPDATE
SET "count"="count"+1
WHERE "table"."unique"=1
RETURNING "table"."id", "table"."unique", "table"."count"

Now PostgreSQL complains:

ERROR:  column reference "count" is ambiguous
LINE 3: SET "count"="count"+1

To fix this, column "count" should be qualified with the table. Using SET "count"="table"."count"+1 works as expected.

I tested this with PostgreSQL 9.6.2 and Persistent 2.6. Older versions of persistent where multiple queries were used did not have the problem.

@psibi

This comment has been minimized.

Show comment
Hide comment
@psibi

psibi Apr 8, 2017

Member

This should be fixed in this PR: #618

Member

psibi commented Apr 8, 2017

This should be fixed in this PR: #618

@psibi

This comment has been minimized.

Show comment
Hide comment
@psibi

psibi Apr 8, 2017

Member

Update: It's not completely fixed and it seems to fail in some special case in recent version of postgresql 9.6.

Member

psibi commented Apr 8, 2017

Update: It's not completely fixed and it seems to fail in some special case in recent version of postgresql 9.6.

@psibi

This comment has been minimized.

Show comment
Hide comment
@psibi

psibi Apr 8, 2017

Member

@rkaminsk

I have updated the PR to include the fixes. Can you give it a try and confirm if it works for you ?

I have tested on Postgresql 9.5.4 and 9.6 and it works for me there.

Member

psibi commented Apr 8, 2017

@rkaminsk

I have updated the PR to include the fixes. Can you give it a try and confirm if it works for you ?

I have tested on Postgresql 9.5.4 and 9.6 and it works for me there.

@rkaminsk

This comment has been minimized.

Show comment
Hide comment
@rkaminsk

rkaminsk Apr 8, 2017

Yes, 22754d3 fixes the issue here! Thanks. -R

rkaminsk commented Apr 8, 2017

Yes, 22754d3 fixes the issue here! Thanks. -R

@psibi

This comment has been minimized.

Show comment
Hide comment
@psibi

psibi Apr 10, 2017

Member

persistent-2.7.0 has been released which fixes this. Closing the issue.

Member

psibi commented Apr 10, 2017

persistent-2.7.0 has been released which fixes this. Closing the issue.

@psibi psibi closed this Apr 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment