pg-mem
pg-mem copied to clipboard
ON CONFLICT <target> does not work when <target> is ON CONSTRAINT
Describe the bug
According to the documentation, the following is valid syntax:
INSERT INTO test (person_id, person_skill)
VALUES('abc', 'programming')
ON CONFLICT ON CONSTRAINT uniq_skill DO UPDATE
SET modified_at = now()
Error
💔 Your query failed to parse.
This is most likely due to a SQL syntax error. However, you might also have hit a bug, or an unimplemented feature of pg-mem.
If this is the case, please file an issue at https://github.com/oguimbal/pg-mem along with a query that reproduces this syntax error.
👉 Failed query:
insert into "test"("person_id","person_skill") values('abc','programming')
ON CONFLICT ON CONSTRAINT uniq_skill DO UPDATE
SET modified_at = now()
;
💀 Syntax error at line 2 col 25:
ON CONFLICT ON
^
Unexpected kw_on token: "on". Instead, I was expecting to see one of the following:
- A "kw_do" token
- A "lparen" token
- A "kw_do" token
To Reproduce
CREATE TABLE test(
id SERIAL PRIMARY KEY,
person_id text NOT NULL,
person_skill text NOT NULL,
created_at timestamp with time zone DEFAULT now(),
modified_at timestamp with time zone DEFAULT now()
);
ALTER TABLE test ADD CONSTRAINT uniq_skill UNIQUE (person_id, person_skill);
INSERT INTO test (person_id, person_skill)
VALUES
('abc', 'tcp/ip'),
('abc', 'programming');
INSERT INTO test (person_id, person_skill)
VALUES('abc', 'programming')
ON CONFLICT ON CONSTRAINT uniq_skill DO UPDATE
SET modified_at = now()
pg-mem version
2.3.5
Hitting the same issue
Fixed in [email protected] ! Sorry for the delay