Skip to content

Conflict target's where should not have a table name #191

Description

@ivankustera

It is nicely stated in the conflict helper that where doesn't need a table name, but it still gets it.

// Where condition doesn't need a table name

If I try something like

{
  type: 'insert',
  table: 'entries',
  values: [
    {
      orgId: '...',
      otherId: '...',
      amount: 1200,
    },
  ],
  conflict: {
    target: {
      columns: [
        'orgId',
        'otherId',
      ],
      where: {
        isDeleted: false,
      },
    },
    action: {
      update: {
        amount: '$excluded.amount$',
      },
    },
  },
}

The result is

insert into "entries" ("orgId", "otherId", "amount") values ($1, $2, $3) 
on conflict ("orgId", "otherId") where "entries"."isDeleted" is false do update set "amount" = "excluded"."amount";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions