Does opaleye support upsert / INSERT ON CONFLICT?

98 views Asked by At

I'm trying to create a query like:

INSERT INTO users (id, level)
VALUES (1, 0)
ON CONFLICT (id) DO UPDATE
SET level = users.level + 1;

However I can't see how to do this with opaleye? Is this not supported?

Strangely we have Insert defined with a field of iOnConflict :: Maybe OnConflict. However OnConflict is defined as: data OnConflict = DoNothing so it just looks like a placeholder for now?

Following through the issue listed on github, I see it leads to this eventual PR: https://github.com/tomjaguarpaw/haskell-opaleye/pull/385/files but I can't really make sense of it? I'm not sure if it's implementing just the placeholder, or it actually implements the functionality.

1

There are 1 answers

0
Tom Ellis On BEST ANSWER

Firstly, you will generally get a quicker, and probably better, response to these kinds of questions if you file a new issue on the Opaleye repo.

Opaleye currently only supports ON CONFLICT DO NOTHING. I'm happy to look into supporting more functionality though. Please chime in with a new issue or on a relevant existing one.