Skip to content

ON CONFLICT DO UPDATE asks for target column but not stated in docs. #1256

@mafuyuuu1

Description

@mafuyuuu1

According to this example, if I do the same as what the example says, I'm getting an error.

await Account.insert(
      Account(
          number=account.number,
          balance=account.balance,
          token=account.token,
          password=account.password,
          device_id=account.device_id,
            )
    ).on_conflict(
            action="DO UPDATE",
            target=Account.number, # Adding this will fix the error but not included in the example in the documentation.
            values=[Account.token],
 )

asyncpg.exceptions.PostgresSyntaxError: ON CONFLICT DO UPDATE requires inference specification or constraint name
HINT:  For example, ON CONFLICT (column_name).

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