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.
Activity
View on GitHub#2612If 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_updatein the unstable Rust implementation, #2678 .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.
- bfops reopened this May 5, 2025
- gefjon reopened this May 5, 2025
Reopening, as the linked PR does not include C# support, and is currently marked unstable.
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.
