classCandidateKeySet
final class CandidateKeySet
Relational candidate keys used to detect INSERT conflicts.
Type Aliases§
Row = import from TableDefinitionMethods§
public function __construct(
private array<string, array<int, string>> $keys,
private CandidateKeyMatch $values = new \ZtdQuery\Schema\Key\CandidateKeyMatch(),
)Parameters
$keys | array<string, array<int, string>> | Columns of each candidate key, under the key's name |
$values | CandidateKeyMatch | Reads what a row carries in a key |
Calls 1
public static function fromSchema(
array<int, string> $primaryKey,
array<string, array<int, string>> $uniqueConstraints = [],
): selfParameters
$primaryKey | array<int, string> | |
$uniqueConstraints | array<string, array<int, string>> |
Returns
selfTest cases 20
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcallsCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycallsCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscallsCandidateKeySetTest::testFromSchemaNamesOnlyTheUniqueKeysWhereThereIsNoPrimaryOnecallsCandidateKeySetTest::testFromSchemaPutsThePrimaryKeyBeforeEveryUniqueOnecallsCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncallsCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcallsCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcallsCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycallsConflictSearchTest::testOfAnswersTheRowTheIncomingRowWouldCollideWithcallsConflictSearchTest::testOfIsNothingWhereNoRowAlreadyThereCarriesTheSameKeycallsConflictSearchTest::testOfIsNothingWhereTheIncomingRowTakesNoPartInTheNarrowedKeycallsConflictSearchTest::testOfLeavesOutTheRowsAlreadyThereThatTakeNoPartcallsConflictSearchTest::testOfReportsTheRowUnderTheKeyTheCallerKnowsItBycallsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecallsUpsertMutationTest::testConflictPredicateRestrictsIncomingAndExistingCandidateRowscallsUpsertMutationTest::testResultRowsAnswersEveryRowTheStatementWroteOrLeftAsItWascallsPgSqlConflictTargetTest::testRegularUniqueIndexTakesPrecedenceOverPartialIndexInferencecallsPgSqlConflictTargetTest::testResolvesNamedConstraintCaseInsensitivelycallsPgSqlConflictTargetTest::testUnspecifiedTargetKeepsEveryRegularCandidateKeycalls
Called from 4
- static-call ZtdQuery\Schema\TableDefinition::candidateKeys() packages/ztd-query-core/src/Schema/TableDefinition.php:121
- static-call ZtdQuery\Shadow\Mutation\Row\InsertMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/Row/InsertMutation.php:91
- static-call ZtdQuery\Shadow\Mutation\Row\ReplaceMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:34
- static-call ZtdQuery\Shadow\Mutation\UpsertMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/UpsertMutation.php:95
Calls 1
- new
selfline 37
public function keys(): array<string, array<int, string>>Returns
array<string, array<int, string>>Test cases 1
Called from 2
- method-call ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:57
- method-call ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:68
public function findConflict(Row $row, array<int, Row> $existingRows): CandidateKeyConflict|nullAnswers 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
Returns
CandidateKeyConflict|null Where and on which key it collides, or null when it does notCalled from 3
- method-call ZtdQuery\Shadow\Mutation\ConflictSearch::of() packages/ztd-query-core/src/Shadow/Mutation/ConflictSearch.php:48
- method-call ZtdQuery\Shadow\Mutation\ConflictSearch::of() packages/ztd-query-core/src/Shadow/Mutation/ConflictSearch.php:61
- method-call ZtdQuery\Shadow\Mutation\Row\ReplaceMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:45
Calls 3
- method-call CandidateKeyMatch::of() line 63
- method-call CandidateKeyMatch::carriedBy() line 69
- new CandidateKeyConflict line 70
Private surface 2§
Implementation details, listed for orientation only.
private array<string, array<int, string>> $keysprivate CandidateKeyMatch $values = new \ZtdQuery\Schema\Key\CandidateKeyMatch()Test cases 34§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcallsCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycallsCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscallsCandidateKeySetTest::testFromSchemaNamesOnlyTheUniqueKeysWhereThereIsNoPrimaryOnecallsCandidateKeySetTest::testFromSchemaPutsThePrimaryKeyBeforeEveryUniqueOnecallsCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncallsCandidateKeySetTest::testKeysAnswersTheColumnsOfEveryKeyItWasBuiltFromcallsCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcallsCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcallsCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycalls
Other tests reaching this symbol 24
RewritePlanTestcallsTableDefinitionTestcallsSessionTestcallsConflictSearchTest::testOfAnswersTheRowTheIncomingRowWouldCollideWithcallsConflictSearchTest::testOfIsNothingWhereNoRowAlreadyThereCarriesTheSameKeycallsConflictSearchTest::testOfIsNothingWhereTheIncomingRowTakesNoPartInTheNarrowedKeycallsConflictSearchTest::testOfLeavesOutTheRowsAlreadyThereThatTakeNoPartcallsConflictSearchTest::testOfReportsTheRowUnderTheKeyTheCallerKnowsItBycallsMutationImpactTestcallsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecallsReplaceMutationTestcallsShadowMutationTestcallsSynchronizeMutationTestcallsUpsertMutationTest::testConflictPredicateRestrictsIncomingAndExistingCandidateRowscallsUpsertMutationTest::testResultRowsAnswersEveryRowTheStatementWroteOrLeftAsItWascallsReferentialIntegrityEnforcerTestcallsShadowApplicationTestcallsStatementSimulatorTestcallsPgSqlConflictTargetTest::testRegularUniqueIndexTakesPrecedenceOverPartialIndexInferencecallsPgSqlConflictTargetTest::testRejectsAmbiguousPartialIndexescallsPgSqlConflictTargetTest::testRejectsPartialIndexWithDifferentColumnAritycallsPgSqlConflictTargetTest::testResolvesNamedConstraintCaseInsensitivelycallsPgSqlConflictTargetTest::testResolvesPartialIndexWithOrderIndependentColumnscallsPgSqlConflictTargetTest::testUnspecifiedTargetKeepsEveryRegularCandidateKeycalls
Relations§
Instantiated in 4
- new ZtdQuery\Platform\Postgres\Rewrite\Transformer\Insert\UpsertProjection::projectUpsert() packages/ztd-query-postgres/src/Rewrite/Transformer/Insert/UpsertProjection.php:46
- new ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:59
- new ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:74
- new ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:87
Static calls 4
- static-call ZtdQuery\Schema\TableDefinition::candidateKeys() packages/ztd-query-core/src/Schema/TableDefinition.php:121
- static-call ZtdQuery\Shadow\Mutation\Row\InsertMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/Row/InsertMutation.php:91
- static-call ZtdQuery\Shadow\Mutation\Row\ReplaceMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:34
- static-call ZtdQuery\Shadow\Mutation\UpsertMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/UpsertMutation.php:95
Method calls 5
- method-call ZtdQuery\Shadow\Mutation\ConflictSearch::of() packages/ztd-query-core/src/Shadow/Mutation/ConflictSearch.php:48
- method-call ZtdQuery\Shadow\Mutation\ConflictSearch::of() packages/ztd-query-core/src/Shadow/Mutation/ConflictSearch.php:61
- method-call ZtdQuery\Shadow\Mutation\Row\ReplaceMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:45
- method-call ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:57
- method-call ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget::resolve() packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:68
Type declarations 10
- type ZtdQuery\Schema\TableDefinition packages/ztd-query-core/src/Schema/TableDefinition.php:119
- type ZtdQuery\Shadow\Mutation\ConflictSearch packages/ztd-query-core/src/Shadow/Mutation/ConflictSearch.php:29
- type ZtdQuery\Shadow\Mutation\Row\InsertMutation packages/ztd-query-core/src/Shadow/Mutation/Row/InsertMutation.php:58
- type ZtdQuery\Shadow\Mutation\Row\InsertMutation packages/ztd-query-core/src/Shadow/Mutation/Row/InsertMutation.php:83
- type ZtdQuery\Shadow\Mutation\Row\ReplaceMutation packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:24
- type ZtdQuery\Shadow\Mutation\Row\ReplaceMutation packages/ztd-query-core/src/Shadow/Mutation/Row/ReplaceMutation.php:31
- type ZtdQuery\Shadow\Mutation\UpsertMutation packages/ztd-query-core/src/Shadow/Mutation/UpsertMutation.php:48
- type ZtdQuery\Shadow\Mutation\UpsertMutation packages/ztd-query-core/src/Shadow/Mutation/UpsertMutation.php:81
- type ZtdQuery\Platform\Postgres\Shadow\Mutation\Row\RowMutationResolver packages/ztd-query-postgres/src/Shadow/Mutation/Row/RowMutationResolver.php:191
- type ZtdQuery\Platform\Postgres\Sql\Conflict\PgSqlConflictTarget packages/ztd-query-postgres/src/Sql/Conflict/PgSqlConflictTarget.php:50