nilenso / honeysql-postgres

PostgreSQL extension for honeysql
http://nilenso.com
Eclipse Public License 1.0
193 stars 28 forks source link

Fix query-values priority #32

Closed b-ryan closed 5 years ago

b-ryan commented 5 years ago

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 commented 5 years ago

Thanks for the PR @b-ryan

Merging this.