Request Details

Something like this:

// Pseudocode
func upsert(ctx, primary_key_value, value):
  if ctx.primary_key_column.try_find(primary_key_value):
    // Row with a matching primary key column exists
    ctx.primary_key_column.delete(primary_key_value)
  ctx.primary_key_column.insert(primary_key_value, value)
  

In order to upsert on a column it needs to have a unique constraint on it.

  1. bfops renamed to "Feature request: `insert_or_update` ("upsert")" Jun 19, 2025
  2. If I may, perhaps the name "InsertOrUpdate" or similar would be better. Yes, it's longer, but there is then no ambiguity on first glance about what the function does.

    @sunkin351 We did indeed settle on insert_or_update in the unstable Rust implementation, #2678 .

  3. If I may, perhaps the name "InsertOrUpdate" or similar would be better. Yes, it's longer, but there is then no ambiguity on first glance about what the function does.

  4. bfops reopened this May 5, 2025
  5. bfops closed this as completed May 5, 2025
  6. gefjon reopened this May 5, 2025
  7. Reopening, as the linked PR does not include C# support, and is currently marked unstable.

  8. cloutiertyler closed this as completed May 2, 2025
  9. This can probably be implemented for now in module bindings as "try-update, insert on row-doesn't-exist" so that we don't have to add this in the host. If it turns out that this needs to be highly optimized we can add an ABI for it later on.

  10. jdetter added the feature-request label Apr 14, 2025

Reopen this request?

The request will return to its prior live status.

Mark as Duplicate

Pick the request that Feature request: `insert_or_update` ("upsert") is a duplicate of. Energy rolls up into that request and GitHub closes the linked issue as a duplicate with a timeline reference to the canonical.

Unmark Duplicate

Restore as an independent request. The linked GitHub issue will be reopened and its duplicate-of relationship cleared. The original timeline entries stay as history; the note below is posted as a follow-up comment.