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

upsert broken in recent persistent versions #662

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

upsert broken in recent persistent versions #662

rkaminsk opened this issue Apr 7, 2017 · 5 comments

Comments

@rkaminsk
Copy link

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
Copy link
Member

psibi commented Apr 8, 2017

This should be fixed in this PR: #618

@psibi
Copy link
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
Copy link
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
Copy link
Author

rkaminsk commented Apr 8, 2017

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

@psibi
Copy link
Member

psibi commented Apr 10, 2017

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

@psibi psibi closed this as completed Apr 10, 2017
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

No branches or pull requests

2 participants