Skip to content

Postgres Upsert with UpdateByProperties not working #133

@swimmesberger

Description

@swimmesberger

When using the function BulkInsertOrUpdate with UpdateByProperties with postgres an error occurs:

 CREATE INDEX CONCURRENTLY cannot run inside a transaction block
       ---> Npgsql.PostgresException (0x80004005): 25001: CREATE INDEX CONCURRENTLY cannot run inside a transaction block

The issue seems to be in PostgreSqlQueryBuilder.CountUniqueConstrain, there is a check only for constraints, but an index can also be marked as unique, producing identical uniqueness behavior.

So I have no explicit unique constraint on the property but a unique index.

A possible workaround is to define the property defined in UpdateByProperties as ef core alternate key (HasAlternateKey) instead of unique index (HasIndex(x => ...).IsUnique()).
This will create a constraint behind the scenes additionally to the unique index.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions