Documentation

No matching pages.

API

Config

Facade

Lifecycle

Class: ConflictTarget

Full name: Azera\Orm\ConflictTarget

The uniqueness key an UPSERT conflicts on: a column list plus, when the index is PARTIAL, its predicate.

Without this, EntityManager::upsert() can only conflict on the primary key — which is useless for the two shapes that actually need an atomic upsert:

  • a DB-GENERATED primary key (uuid/int), where the caller has no PK to name before the row exists, and
  • a natural key such as stripe_customer_id, where the PK is incidental and the uniqueness the caller cares about is a separate index.

The predicate is not cosmetic. PostgreSQL matches an ON CONFLICT target against a unique index by inference, and a PARTIAL index is only inferred when the statement repeats its predicate. Both halves of this object therefore travel together into the statement; dropping the predicate turns a working upsert into "there is no_unique_constraint matching the ON CONFLICT specification".

Immutable: a target is queued on a Node and must not change under a later flush.

Public Properties

  • public readonly array $columns ·
  • public readonly string|null $where ·

Public methods

columns() ·

public static function columns(array $columns, string|null $where = null): Azera\Orm\ConflictTarget

A conflict target on $columns, optionally constrained to the partial index whose predicate is $where.

Parameters

Name Type Default Description
$columns array -
$where string|null null

Return value


isPartial() ·

public function isPartial(): bool

True when the target addresses a partial (predicate) index.

Return value

  • Type: bool

Back to the Index