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

Postgres 17 mergeInto with returning #1169

Open
asterikx opened this issue Oct 5, 2024 · 1 comment
Open

Postgres 17 mergeInto with returning #1169

asterikx opened this issue Oct 5, 2024 · 1 comment
Assignees
Labels
api Related to library's API enhancement New feature or request postgres Related to PostgreSQL

Comments

@asterikx
Copy link

asterikx commented Oct 5, 2024

Postgres 17 now supports MERGE INTO with RETURNING (which is very handy to streamline queries and upsert records without writing multiple queries).

MERGE INTO heroes AS h
USING (VALUES ('Wade', 'Wilson', 'Deadpool')) AS v(first_name, last_name, hero_name)
ON h.hero_name = v.hero_name
WHEN MATCHED THEN
  UPDATE SET first_name = v.first_name, last_name = v.last_name
WHEN NOT MATCHED THEN
  INSERT (first_name, last_name, hero_name)
  VALUES (v.first_name, v.last_name, v.hero_name)
RETURNING merge_action(), *;

Is it possible to create the preceding query (taken from the Neon release note) with Kysely?

@asterikx asterikx changed the title Postgres 17 mergeInto with returningAll Postgres 17 mergeInto with returning Oct 5, 2024
@igalklebanov
Copy link
Member

Hey 👋

Not yet.

@igalklebanov igalklebanov added enhancement New feature or request postgres Related to PostgreSQL api Related to library's API labels Oct 5, 2024
@igalklebanov igalklebanov self-assigned this Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request postgres Related to PostgreSQL
Projects
None yet
Development

No branches or pull requests

2 participants