Skip to content

Conversation

@b-ryan
Copy link
Contributor

@b-ryan b-ryan commented Apr 6, 2019

When used with an upsert clause, query-values was not being rendered
with the correct priority. The provided test fails on master and passes
on this branch. It was previously rendering the SQL as:

INSERT INTO distributors (did, dname)
ON CONFLICT ON CONSTRAINT distributors_pkey DO NOTHING
(SELECT ?, ?)

which is not valid SQL. The below snippet from psql demonstrates this
not working:

muncher=# insert into foo (id) select 1 on conflict do nothing;
INSERT 0 1
muncher=# insert into foo (id) on conflict do nothing (select 1);
ERROR:  syntax error at or near "on"
LINE 1: insert into foo (id) on conflict do nothing (select 1);

When used with an upsert clause, query-values was not being rendered
with the correct priority. The provided test fails on master and passes
on this branch. It was previously rendering the SQL as:

```
INSERT INTO distributors (did, dname)
ON CONFLICT ON CONSTRAINT distributors_pkey DO NOTHING
(SELECT ?, ?)
```

which is not valid SQL. The below snippet from psql demonstrates this
not working:

```
muncher=# insert into foo (id) select 1 on conflict do nothing;
INSERT 0 1
muncher=# insert into foo (id) on conflict do nothing (select 1);
ERROR:  syntax error at or near "on"
LINE 1: insert into foo (id) on conflict do nothing (select 1);
```
@ukriish
Copy link
Contributor

ukriish commented Apr 7, 2019

Thanks for the PR @b-ryan

Merging this.

@ukriish ukriish merged commit f49efa4 into nilenso:master Apr 7, 2019
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