Skip to content

Support partial indexes on upsert #8875

Open
@tjhiggins

Description

Feature Description

The Problem

The repository upsert function seemed like a great way to import a list of entities.
However, I use soft deletes for all of the my tables and therefore have partial indexes like the following:

@Index(['account', 'key'], { where: '"deleted_at" IS NULL', unique: true })

The following fails because the upsert doesn't include the where clause for deleted_at:

await repository.upsert(
  [...],
  ['account', 'key'],
);

The Solution

Ideally I'd be able to use find options as a third arg to the upsert function:

await repository.upsert(
  [...],
  ['account', 'key'],
  { where: { deleted_at: IsNull() } }
);

Additional Context

Relevant Database Driver(s)

DB Type Relevant
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb yes
cordova no
expo no
mongodb yes
mysql no
nativescript no
oracle no
postgres yes
react-native no
sap no
sqlite yes
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions