0

In table:

CONSTRAINT unique_position UNIQUE (id,city,type)
CREATE UNIQUE INDEX unique_position_sat_null ON public."position" (id,city) where type is null

When we insert into a table with iBatis we'd like to use:

ON CONFLICT ON INDEX unique_position DO UPDATE SET
        .....

As I understand we cannot use index in ON CONFLICT in POSTGRES.

Are there any other options to handle this? Thanks.

Anton Kim
  • 879
  • 13
  • 36

1 Answers1

1

This is duplicated question. I answered in your previous one POSTGRES - Handling several ON CONFLICT constraints/indexes

In short: no, there is currently no way to mention a partial index name in ON CONFLICT clause.

A workaround in your case would be (probably, depending on your logic): stop using NULLs in "type" column at all, use "-1" instead and work with 3-column unique constraint.

Nick
  • 2,423
  • 13
  • 21