classRowMatch
final class RowMatch
Finds a row among rows, by the columns that identify it.
Nothing here knows about foreign keys or about mutations. It answers the one question every part of the shadow keeps asking — is this the same row, and where is it — so that the answer is given the same way everywhere.
Type Aliases§
Row = import from TableDefinitionRowValue = import from TableDefinitionMethods§
Reads the values a row carries in the named columns.
A row that does not carry one of them cannot be compared on them at all, which is different from carrying null there, so it answers nothing rather than a list with a hole in it.
Parameters
$row | Row | Row to read |
$columns | list<string> | Columns to read, in order |
Returns
list<RowValue>|null The values, or null when the row lacks one of the columnsTest cases 3
RowMatchTest::testValuesOfAnswersNothingWhenTheRowLacksAColumncovers and callsRowMatchTest::testValuesOfKeepsANullTheRowActuallyCarriescovers and callsRowMatchTest::testValuesOfReadsTheColumnsInTheOrderTheyWereAskedForcovers and calls
Called from 4
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:111
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:112
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:147
- method-call ZtdQuery\Shadow\ForeignKeyIntegrity::assertHolds() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:53
Calls 1
- function-call
array_key_existsline 37
Reports whether a row carries exactly these values in these columns.
Parameters
Returns
bool True when every column carries the value paired with itTest cases 3
RowMatchTest::testCarriesIsFalseWhenTheRowLacksAColumncovers and callsRowMatchTest::testCarriesIsTrueOnlyWhenEveryColumnHoldsTheValuePairedWithItcovers and callsRowMatchTest::testCarriesTellsAStringApartFromTheNumberItLooksLikecovers and calls
Called from 3
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:121
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:156
- method-call ZtdQuery\Shadow\ParentKeyLookup::exists() packages/ztd-query-core/src/Shadow/ParentKeyLookup.php:41
Calls 1
- function-call
array_key_existsline 58
Reports whether two rows agree on the named columns.
Returns
bool True when both carry every key and carry it identicallyTest cases 11
RowMatchTest::testAgreeOnComparesOnlyTheNamedColumnscovers and callsRowMatchTest::testAgreeOnIsFalseWhenEitherRowLacksAKeycovers and callsRowMatchTest::testAgreeOnIsTrueForAnyTwoRowsWhenNoKeyIsNamedcovers and callsRowMatchTest::testIdentifiesFallsBackToTheWholeRowWhereTheTableDeclaresNoKeycoversRowMatchTest::testIdentifiesIsFalseWhereTheyDisagreeOnTheKeycoversRowMatchTest::testIdentifiesReportsTwoRowsAgreeingOnTheKeyHoweverElseTheyDiffercoversRowMatchTest::testIdentifiesTellsTwoRowsApartByEverythingWhereThereIsNoKeycoversRowMatchTest::testPositionOfSameKeyAnswersWhereTheKeyMatchescoversRowMatchTest::testPositionOfSameKeySkipsPositionsAlreadyPairedOffcoversRowMatchTest::testSameRowIsFalseWhereTheyDifferInAValuecoversRowMatchTest::testSameRowReportsTwoRowsCarryingTheSameColumnsAndValuescovers
Called from 3
- method-call ZtdQuery\Shadow\Row\RowMatch::sameRow() packages/ztd-query-core/src/Shadow/Row/RowMatch.php:107
- method-call ZtdQuery\Shadow\Row\RowMatch::identifies() packages/ztd-query-core/src/Shadow/Row/RowMatch.php:130
- method-call ZtdQuery\Shadow\Row\RowMatch::positionOfSameKey() packages/ztd-query-core/src/Shadow/Row/RowMatch.php:149
Calls 1
- function-call
array_key_existsline 78
Reports whether two rows carry the same columns with the same values.
Column order is not part of a row's identity: the same columns carrying the same values are the same row however the reader happened to order them.
Returns
bool True when neither carries a column the other lacks, and both agree everywhereTest cases 5
RowMatchTest::testIdentifiesFallsBackToTheWholeRowWhereTheTableDeclaresNoKeycoversRowMatchTest::testIdentifiesTellsTwoRowsApartByEverythingWhereThereIsNoKeycoversRowMatchTest::testSameRowIsFalseWhereOneCarriesAColumnTheOtherLackscovers and callsRowMatchTest::testSameRowIsFalseWhereTheyDifferInAValuecovers and callsRowMatchTest::testSameRowReportsTwoRowsCarryingTheSameColumnsAndValuescovers and calls
Called from 2
Calls 3
- function-call
countline 103 - method-call RowMatch::agreeOn() line 107
- function-call
array_keysline 107
Reports whether two rows are the same row of a table keyed like this.
A table with a key is identified by it, and two rows agreeing on it are the same row however else they differ. A table with no key has nothing to be identified by, so being the same row means carrying everything the same.
Parameters
Returns
bool True when the table cannot tell the two apartTest cases 4
RowMatchTest::testIdentifiesFallsBackToTheWholeRowWhereTheTableDeclaresNoKeycovers and callsRowMatchTest::testIdentifiesIsFalseWhereTheyDisagreeOnTheKeycovers and callsRowMatchTest::testIdentifiesReportsTwoRowsAgreeingOnTheKeyHoweverElseTheyDiffercovers and callsRowMatchTest::testIdentifiesTellsTwoRowsApartByEverythingWhereThereIsNoKeycovers and calls
Called from 3
- method-call ZtdQuery\Shadow\ShadowStore::delete() packages/ztd-query-core/src/Shadow/ShadowStore.php:192
- method-call ZtdQuery\Shadow\ShadowStore::update() packages/ztd-query-core/src/Shadow/ShadowStore.php:228
- method-call ZtdQuery\Shadow\ShadowStore::updateIdentified() packages/ztd-query-core/src/Shadow/ShadowStore.php:256
Calls 3
- method-call RowMatch::sameRow() line 127
- method-call RowMatch::agreeOn() line 130
- function-call
array_valuesline 130
public function positionOfSameKey(
array<int, Row> $rows,
Row $candidate,
list<string> $keys,
list<int> $excluded,
): int|nullAnswers where a row with the same key is, among rows not already taken.
Rows already paired off are excluded so that two rows sharing a key are paired one to one rather than both to the first match.
Parameters
Returns
int|null Position of the match, or null when there is none leftTest cases 3
RowMatchTest::testPositionOfSameKeyAnswersWhereTheKeyMatchescovers and callsRowMatchTest::testPositionOfSameKeyIsNothingWhenNoRowIsLeftToMatchcovers and callsRowMatchTest::testPositionOfSameKeySkipsPositionsAlreadyPairedOffcovers and calls
Called from 4
- method-call ZtdQuery\Shadow\Mutation\Table\SynchronizeMutation::affectedRowCount() packages/ztd-query-core/src/Shadow/Mutation/Table/SynchronizeMutation.php:102
- method-call ZtdQuery\Shadow\TableTransitions::pairByIdentity() packages/ztd-query-core/src/Shadow/TableTransitions.php:153
- method-call ZtdQuery\Shadow\TableTransitions::pairByIdentity() packages/ztd-query-core/src/Shadow/TableTransitions.php:159
- method-call ZtdQuery\Shadow\TableTransitions::pairByKey() packages/ztd-query-core/src/Shadow/TableTransitions.php:186
Calls 2
- function-call
in_arrayline 149 - method-call RowMatch::agreeOn() line 149
public function positionOfIdentical(
array<int, Row> $rows,
Row $candidate,
list<int> $excluded,
): int|nullAnswers where an identical row is, among rows not already taken.
A table with no key has nothing to be identified by, so the whole row is what has to match.
Parameters
Returns
int|null Position of the match, or null when there is none leftTest cases 3
RowMatchTest::testPositionOfIdenticalIsNothingWhenNoRowIsLeftToMatchcovers and callsRowMatchTest::testPositionOfIdenticalNeedsTheWholeRowToMatchcovers and callsRowMatchTest::testPositionOfIdenticalSkipsPositionsAlreadyPairedOffcovers and calls
Called from 1
Calls 1
- function-call
in_arrayline 172
Test cases 38§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 22
RowMatchTest::testAgreeOnComparesOnlyTheNamedColumnscovers and callsRowMatchTest::testAgreeOnIsFalseWhenEitherRowLacksAKeycovers and callsRowMatchTest::testAgreeOnIsTrueForAnyTwoRowsWhenNoKeyIsNamedcovers and callsRowMatchTest::testCarriesIsFalseWhenTheRowLacksAColumncovers and callsRowMatchTest::testCarriesIsTrueOnlyWhenEveryColumnHoldsTheValuePairedWithItcovers and callsRowMatchTest::testCarriesTellsAStringApartFromTheNumberItLooksLikecovers and callsRowMatchTest::testIdentifiesFallsBackToTheWholeRowWhereTheTableDeclaresNoKeycovers and callsRowMatchTest::testIdentifiesIsFalseWhereTheyDisagreeOnTheKeycovers and callsRowMatchTest::testIdentifiesReportsTwoRowsAgreeingOnTheKeyHoweverElseTheyDiffercovers and callsRowMatchTest::testIdentifiesTellsTwoRowsApartByEverythingWhereThereIsNoKeycovers and callsRowMatchTest::testPositionOfIdenticalIsNothingWhenNoRowIsLeftToMatchcovers and callsRowMatchTest::testPositionOfIdenticalNeedsTheWholeRowToMatchcovers and callsRowMatchTest::testPositionOfIdenticalSkipsPositionsAlreadyPairedOffcovers and callsRowMatchTest::testPositionOfSameKeyAnswersWhereTheKeyMatchescovers and callsRowMatchTest::testPositionOfSameKeyIsNothingWhenNoRowIsLeftToMatchcovers and callsRowMatchTest::testPositionOfSameKeySkipsPositionsAlreadyPairedOffcovers and callsRowMatchTest::testSameRowIsFalseWhereOneCarriesAColumnTheOtherLackscovers and callsRowMatchTest::testSameRowIsFalseWhereTheyDifferInAValuecovers and callsRowMatchTest::testSameRowReportsTwoRowsCarryingTheSameColumnsAndValuescovers and callsRowMatchTest::testValuesOfAnswersNothingWhenTheRowLacksAColumncovers and callsRowMatchTest::testValuesOfKeepsANullTheRowActuallyCarriescovers and callsRowMatchTest::testValuesOfReadsTheColumnsInTheOrderTheyWereAskedForcovers and calls
Other tests reaching this symbol 16
SessionTestcallsForeignKeyCascadeTestcallsForeignKeyIntegrityTestcallsMutationImpactTestcallsDeleteMutationTestcallsMultiDeleteMutationTestcallsMultiUpdateMutationTestcallsUpdateMutationTestcallsShadowMutationTestcallsSynchronizeMutationTestcallsParentKeyLookupTestcallsReferentialIntegrityEnforcerTestcallsRowMultisetTestcallsShadowApplicationTestcallsShadowStoreTestcallsTableTransitionsTestcalls
Relations§
Instantiated in 7
- new ZtdQuery\Shadow\ForeignKeyCascade::__construct() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:41
- new ZtdQuery\Shadow\ForeignKeyIntegrity::__construct() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:31
- new ZtdQuery\Shadow\Mutation\Table\SynchronizeMutation::__construct() packages/ztd-query-core/src/Shadow/Mutation/Table/SynchronizeMutation.php:35
- new ZtdQuery\Shadow\ParentKeyLookup::__construct() packages/ztd-query-core/src/Shadow/ParentKeyLookup.php:24
- new ZtdQuery\Shadow\Row\RowMultiset::__construct() packages/ztd-query-core/src/Shadow/Row/RowMultiset.php:27
- new ZtdQuery\Shadow\ShadowStore::__construct() packages/ztd-query-core/src/Shadow/ShadowStore.php:33
- new ZtdQuery\Shadow\TableTransitions::__construct() packages/ztd-query-core/src/Shadow/TableTransitions.php:40
Method calls 16
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:111
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:112
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:121
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:147
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:156
- method-call ZtdQuery\Shadow\ForeignKeyIntegrity::assertHolds() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:53
- method-call ZtdQuery\Shadow\Mutation\Table\SynchronizeMutation::affectedRowCount() packages/ztd-query-core/src/Shadow/Mutation/Table/SynchronizeMutation.php:102
- method-call ZtdQuery\Shadow\ParentKeyLookup::exists() packages/ztd-query-core/src/Shadow/ParentKeyLookup.php:41
- method-call ZtdQuery\Shadow\Row\RowMultiset::difference() packages/ztd-query-core/src/Shadow/Row/RowMultiset.php:46
- method-call ZtdQuery\Shadow\ShadowStore::delete() packages/ztd-query-core/src/Shadow/ShadowStore.php:192
- method-call ZtdQuery\Shadow\ShadowStore::update() packages/ztd-query-core/src/Shadow/ShadowStore.php:228
- method-call ZtdQuery\Shadow\ShadowStore::updateIdentified() packages/ztd-query-core/src/Shadow/ShadowStore.php:256
- method-call ZtdQuery\Shadow\TableTransitions::pairIdentical() packages/ztd-query-core/src/Shadow/TableTransitions.php:124
- method-call ZtdQuery\Shadow\TableTransitions::pairByIdentity() packages/ztd-query-core/src/Shadow/TableTransitions.php:153
- method-call ZtdQuery\Shadow\TableTransitions::pairByIdentity() packages/ztd-query-core/src/Shadow/TableTransitions.php:159
- method-call ZtdQuery\Shadow\TableTransitions::pairByKey() packages/ztd-query-core/src/Shadow/TableTransitions.php:186
Type declarations 7
- type ZtdQuery\Shadow\ForeignKeyCascade packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:41
- type ZtdQuery\Shadow\ForeignKeyIntegrity packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:31
- type ZtdQuery\Shadow\Mutation\Table\SynchronizeMutation packages/ztd-query-core/src/Shadow/Mutation/Table/SynchronizeMutation.php:35
- type ZtdQuery\Shadow\ParentKeyLookup packages/ztd-query-core/src/Shadow/ParentKeyLookup.php:24
- type ZtdQuery\Shadow\Row\RowMultiset packages/ztd-query-core/src/Shadow/Row/RowMultiset.php:27
- type ZtdQuery\Shadow\ShadowStore packages/ztd-query-core/src/Shadow/ShadowStore.php:33
- type ZtdQuery\Shadow\TableTransitions packages/ztd-query-core/src/Shadow/TableTransitions.php:40