Skip to content

Configure whether UPSERT should update all columns, or no column.#1852

Merged
groue merged 1 commit intodevelopmentfrom
dev/upsert-strategy
Feb 15, 2026
Merged

Configure whether UPSERT should update all columns, or no column.#1852
groue merged 1 commit intodevelopmentfrom
dev/upsert-strategy

Conversation

@groue
Copy link
Copy Markdown
Owner

@groue groue commented Feb 14, 2026

This pull request addresses #1833:

// In case of conflict, updates all columns, including columns added
// in a future migration.
let upserted = try player.upsertAndFetch(db)

// In case of conflict, updates all columns, including future ones,
// but 'score'.
let upserted = try player.upsertAndFetch(db) { _ in
    [Column("score").noOverwrite]
}

// NEW! In case of conflict, do not update any column.
let upserted = try player.upsertAndFetch(db, updating: .noColumnUnlessSpecified)

// NEW! In case of conflict, only update 'name'.
let upserted = try player.upsertAndFetch(db, updating: .noColumnUnlessSpecified) { excluded in
    [Column("name").set(to: excluded[Column("name")])]
}

@groue groue force-pushed the dev/upsert-strategy branch 3 times, most recently from 6870548 to 0bdc13f Compare February 15, 2026 12:14
@groue groue force-pushed the dev/upsert-strategy branch from 0bdc13f to 7b01c9b Compare February 15, 2026 12:40
@groue groue merged commit 819f457 into development Feb 15, 2026
15 of 16 checks passed
@groue groue deleted the dev/upsert-strategy branch February 15, 2026 13:10
@jubishop
Copy link
Copy Markdown

thanks! I adopted this here jubishop/podhaven@54972ad . cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants