final class CandidateKeySet

Relational candidate keys used to detect INSERT conflicts.

Type Aliases§

Row = import from TableDefinition

Methods§

public static function fromSchema(
    array<int, string> $primaryKey,
    array<string, array<int, string>> $uniqueConstraints = [],
): self

Parameters

$primaryKeyarray<int, string>
$uniqueConstraintsarray<string, array<int, string>>

Returns

self
Test cases 17
Called from 4
Calls 1
public function findConflict(Row $row, array<int, Row> $existingRows): CandidateKeyConflict|null

Answers the first candidate key an incoming row would collide on.

The rows searched may be keyed, and the conflict reports the key it was found at: a caller that has narrowed the rows it is willing to collide with still has to say which of its own rows that was.

Parameters

$rowRowRow that would be written
$existingRowsarray<int, Row>Rows it could collide with, under the keys the caller knows them by

Returns

CandidateKeyConflict|null Where and on which key it collides, or null when it does not
Test cases 7
Called from 3
Calls 3

Private surface 2§

Implementation details, listed for orientation only.

private array<string, array<int, string>> $keys
private CandidateKeyMatch $values = new \ZtdQuery\Schema\Key\CandidateKeyMatch()

Test cases 28§

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

Dedicated tests 10
Other tests reaching this symbol 18

Relations§

Static calls 4
Method calls 3
Constant reads 1
Type declarations 8