kysely icon indicating copy to clipboard operation
kysely copied to clipboard

add `returning` support in `MERGE` queries.

Open igalklebanov opened this issue 1 year ago • 1 comments

Hey 👋

closes #1169.

As of PostgreSQL 17, MERGE queries now have returning clause support.

  • [x] add returning/returningAll to MERGE.
  • [x] add MultiTableReturningInterface, enforce it across DeleteQueryBuilder, UpdateQueryBuilder and MERGE builders. Why? the existing ReturningInterface doesn't have the returningAll(tables) methods, and INSERT queries are the only ones that don't support returning table.*.
  • [x] add a way to return merge_action() in a type-safe and aliasable way - a PostgreSQL helper function was found to be the lightest solution. Expanding the ExpressionBuilder locally (only for returning) with eb.mergeAction() was also tested, but was adding way more changes. I think that with documentation we could nullify the worse discoverability.
  • [x] unit tests.
  • [x] typings tests.

igalklebanov avatar Oct 07 '24 00:10 igalklebanov

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2024 2:20pm

vercel[bot] avatar Oct 07 '24 00:10 vercel[bot]

Open in Stackblitzkysely_koa_example

npm i https://pkg.pr.new/kysely-org/kysely@1171

commit: c0dc22f

pkg-pr-new[bot] avatar Nov 24 '24 00:11 pkg-pr-new[bot]