final class UpsertMutation
    implements DataMutation

Applies INSERT ... ON DUPLICATE KEY UPDATE (UPSERT) to the shadow store.

Type Aliases§

Row = import from TableDefinition

Methods§

public function __construct(
    string $tableName,
    array<int, string> $primaryKeys,
    array<int, string> $updateColumns = [],
    array<string, UpsertExpression|null> $updateValues = [],
    CandidateKeySet|null $candidateKeys = null,
    UpsertExpression|null $updatePredicate = null,
    bool $databaseEvaluated = false,
    array<string, string> $updateSqlValues = [],
    ?string $updateSqlPredicate = null,
    ?UpsertExpression $conflictPredicate = null,
)

Parameters

$tableNamestringTarget table.
$primaryKeysarray<int, string>Primary key columns.
$updateColumnsarray<int, string>Columns to update on duplicate.
$updateValuesarray<string, UpsertExpression|null>Values to use for update on duplicate.
$candidateKeysCandidateKeySet|nullCandidate keys used for conflict detection.
$updatePredicateUpsertExpression|nullCondition that controls the conflict update.
$databaseEvaluatedbool
$updateSqlValuesarray<string, string>Raw expressions used only for database-evaluation diagnostics.
$updateSqlPredicate?string
$conflictPredicate?UpsertExpression
Calls 4
public function apply(ShadowStore $store, array $rows): void

{@inheritDoc}

Parameters

$storeShadowStore
$rowsarray

Throws

UnsupportedSqlException When an assignment is written in a way ZTD cannot work out
Test cases 24
Calls 8
public function tableName(): string

{@inheritDoc}

Returns

string
Test cases 1

Private surface 13§

Implementation details, listed for orientation only.

private string $tableName
private array<int, string> $primaryKeys
private array<int, string> $updateColumns
private array<string, UpsertExpression|null> $updateValues
private CandidateKeySet $candidateKeys
private ?UpsertExpression $updatePredicate
private ?UpsertExpression $conflictPredicate
private bool $databaseEvaluated
private array<string, string> $updateSqlValues
private ?string $updateSqlPredicate
private RowSet $resultRows
private ConflictSearch $conflicts
private UpsertUpdate $update

Test cases 62§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 24
Other tests reaching this symbol 38

Relations§

Instantiated in 3
Type checks 3