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 |
Test cases 10
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcoversCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycoversCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscoversCandidateKeySetTest::testFromSchemaNamesOnlyTheUniqueKeysWhereThereIsNoPrimaryOnecoversCandidateKeySetTest::testFromSchemaPutsThePrimaryKeyBeforeEveryUniqueOnecoversCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncoversCandidateKeySetTest::testKeysAnswersTheColumnsOfEveryKeyItWasBuiltFromcoversCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcoversCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcoversCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycovers
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 17
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcovers and callsCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycovers and callsCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscovers and callsCandidateKeySetTest::testFromSchemaNamesOnlyTheUniqueKeysWhereThereIsNoPrimaryOnecovers and callsCandidateKeySetTest::testFromSchemaPutsThePrimaryKeyBeforeEveryUniqueOnecovers and callsCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncovers and callsCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcovers and callsCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcovers and callsCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycovers and callsConflictSearchTest::testOfAnswersTheRowTheIncomingRowWouldCollideWithcallsConflictSearchTest::testOfIsNothingWhereNoRowAlreadyThereCarriesTheSameKeycallsConflictSearchTest::testOfIsNothingWhereTheIncomingRowTakesNoPartInTheNarrowedKeycallsConflictSearchTest::testOfLeavesOutTheRowsAlreadyThereThatTakeNoPartcallsConflictSearchTest::testOfReportsTheRowUnderTheKeyTheCallerKnowsItBycallsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecallsUpsertMutationTest::testConflictPredicateRestrictsIncomingAndExistingCandidateRowscallsUpsertMutationTest::testResultRowsAnswersEveryRowTheStatementWroteOrLeftAsItWascalls
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>>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 notTest cases 7
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcoversCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycoversCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscoversCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncoversCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcoversCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcoversCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycovers
Called 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 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
CandidateKeySetTest::testEmptyKeySetNeverTreatsEqualRowsAsConflictingcovers and callsCandidateKeySetTest::testFindConflictIsNothingWhereNoRowCarriesTheSameKeycovers and callsCandidateKeySetTest::testFindsConflictAcrossPrimaryAndUniqueCandidateKeyscovers and callsCandidateKeySetTest::testFromSchemaNamesOnlyTheUniqueKeysWhereThereIsNoPrimaryOnecovers and callsCandidateKeySetTest::testFromSchemaPutsThePrimaryKeyBeforeEveryUniqueOnecovers and callsCandidateKeySetTest::testIncompletePrimaryKeyDoesNotPreventUniqueKeyConflictDetectioncovers and callsCandidateKeySetTest::testKeysAnswersTheColumnsOfEveryKeyItWasBuiltFromcovers and callsCandidateKeySetTest::testMissingCandidateKeyValueDoesNotConflictWithStoredNullcovers and callsCandidateKeySetTest::testMissingStoredKeyValueDoesNotConflictcovers and callsCandidateKeySetTest::testNullDoesNotConflictOnCompositeUniqueKeycovers and calls
Other tests reaching this symbol 18
RewritePlanTestcallsTableDefinitionTestcallsSessionTestcallsConflictSearchTest::testOfAnswersTheRowTheIncomingRowWouldCollideWithcallsConflictSearchTest::testOfIsNothingWhereNoRowAlreadyThereCarriesTheSameKeycallsConflictSearchTest::testOfIsNothingWhereTheIncomingRowTakesNoPartInTheNarrowedKeycallsConflictSearchTest::testOfLeavesOutTheRowsAlreadyThereThatTakeNoPartcallsConflictSearchTest::testOfReportsTheRowUnderTheKeyTheCallerKnowsItBycallsMutationImpactTestcallsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecallsReplaceMutationTestcallsShadowMutationTestcallsSynchronizeMutationTestcallsUpsertMutationTest::testConflictPredicateRestrictsIncomingAndExistingCandidateRowscallsUpsertMutationTest::testResultRowsAnswersEveryRowTheStatementWroteOrLeftAsItWascallsReferentialIntegrityEnforcerTestcallsShadowApplicationTestcallsStatementSimulatorTestcalls
Relations§
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 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
Constant reads 1
- class-const packages/ztd-query-core/src/Compatibility/ClassAliases.php packages/ztd-query-core/src/Compatibility/ClassAliases.php:37
Type declarations 8
- 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