Skip to content

Support ON CONFLICT DO UPDATE ... EXCLUDED #72

Open
@tschuchortdev

Description

@tschuchortdev

Currently, the onConflictUpdate function is defined as follows:

def onConflictUpdate(c: (Q => Column[?])*)(c2: (Q => Column.Assignment[?])*)

From the examples:

Buyer.insert
  .columns(
    _.name := "test buyer",
    _.dateOfBirth := LocalDate.parse("2023-09-09"),
    _.id := 1 // This should cause a primary key conflict
  )
  .onConflictUpdate(_.id)(_.name := "TEST BUYER CONFLICT")

As we can see, the c2 parameter assigns the values that should be SET in the UPDATE and takes only one paramater Q which is the currently inserted row. In postgres at least it is also possible to access the conflicting row through EXCLUDED. onConflictUpdate should thus have two Q parameters, if the database supports it. (See implementation in Quill for example: https://zio.dev/zio-quill/writing-queries/#update-on-conflict)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions