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

ExampleDoUpdate does't work in postgres #156

Closed
1 task done
asv opened this issue Sep 12, 2019 · 1 comment
Closed
1 task done

ExampleDoUpdate does't work in postgres #156

asv opened this issue Sep 12, 2019 · 1 comment

Comments

@asv
Copy link

asv commented Sep 12, 2019

Describe the bug

func ExampleDoUpdate() {

In the generated SQL, the EXCLUDED keyword is escaped according to goqu.I rules, however the resulting SQL is not valid for postgres.

INSERT INTO "items" ("address") VALUES ('111 Address') ON CONFLICT (address) DO UPDATE SET "address"="EXCLUDED"."address";
ERROR:  missing FROM-clause entry for table "EXCLUDED"
LINE 1: ...s') ON CONFLICT (address) DO UPDATE SET "address"="EXCLUDED"...

To Reproduce

Try to execute the generated code in Postgres.

Expected behavior

Statement must be successfully executed.

Dialect:

  • postgres
@doug-martin
Copy link
Owner

@asv good catch I took the example from https://www.postgresql.org/docs/9.5/sql-insert.html.

From the postgres docs.

Insert or update new distributors as appropriate. Assumes a unique index has been defined that constrains values appearing in the did column. Note that the special excluded table is used to reference values originally proposed for insertion:

INSERT INTO distributors (did, dname)
    VALUES (5, 'Gizmo Transglobal'), (6, 'Associated Computing, Inc')
    ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname;

But it appears that wont actually work.

doug-martin added a commit that referenced this issue Sep 19, 2019
* [FIXED] ExampleDoUpdate does't work in postgres #156
@doug-martin doug-martin mentioned this issue Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants