classMutationRowIdentity
final class MutationRowIdentity
Carries the key a row had, alongside the key it has.
An UPDATE may change the very columns that identify a row, and once it has, nothing in the result says which row each new one used to be. The rewritten statement therefore selects the old key as well, under a name no table would use, and this is what puts that name on and takes it off again.
Type Aliases§
Row = import from TableDefinitionMethods§
public function column(string $primaryKey): stringAnswers the name the old value of a key column is carried under.
Parameters
$primaryKey | string | Key column |
Returns
string Name no table would use for itTest cases 8
MutationRowIdentityTest::testColumnBuildsReservedMetadataColumnNamecovers and callsMutationRowIdentityTest::testExtractCarriesNoKeyWhereTheRowHasNoneOfItcoversMutationRowIdentityTest::testExtractReadsAnUnchangedKeyAsItsOwnOldValuecoversMutationRowIdentityTest::testExtractSplitsTheRowFromTheKeyItUsedToHavecoversMutationRowIdentityTest::testFallsBackToCurrentKeyForLegacyProjectionscoversMutationRowIdentityTest::testSeparatesOriginalCompositeKeyFromTheUpdatedRowcoversTableTransitionsTest::testPairByIdentityLeavesARowNoResultRowSpeaksForcallsTableTransitionsTest::testPairByIdentityTakesThePairsAnUpdateToldUsAboutcalls
Called from 1
Calls 1
- class-const MutationRowIdentity::PREFIX() line 32
Takes the carried names back off a row.
Parameters
$row | Row | Row as the rewritten statement read it back |
Returns
Row The row as the caller should see itTest cases 2
Called from 1
Calls 3
- function-call
array_keysline 44 - function-call
str_starts_withline 45 - class-const MutationRowIdentity::PREFIX() line 45
Takes the carried names back off every one of these rows.
Parameters
$rows | array<int, Row> | Rows as the rewritten statement read them back |
Returns
array<int, Row> The rows as the caller should see themTest cases 2
MutationRowIdentityTest::testStripAllAnswersNothingForNoRowscovers and callsMutationRowIdentityTest::testStripAllTakesTheCarriedNamesOffEveryRowcovers and calls
Called from 2
Calls 2
- function-call
array_mapline 62 - method-call MutationRowIdentity::strip() line 62
Splits a row into the row itself and the key it used to have.
A key column the statement did not change carries no old value, so its current one is the old one too.
Parameters
$row | Row | Row as the rewritten statement read it back |
$primaryKeys | list<string> | Columns that identify one row |
Test cases 5
MutationRowIdentityTest::testExtractCarriesNoKeyWhereTheRowHasNoneOfItcovers and callsMutationRowIdentityTest::testExtractReadsAnUnchangedKeyAsItsOwnOldValuecovers and callsMutationRowIdentityTest::testExtractSplitsTheRowFromTheKeyItUsedToHavecovers and callsMutationRowIdentityTest::testFallsBackToCurrentKeyForLegacyProjectionscovers and callsMutationRowIdentityTest::testSeparatesOriginalCompositeKeyFromTheUpdatedRowcovers and calls
Called from 2
Calls 2
- method-call MutationRowIdentity::column() line 80
- function-call
array_key_existsline 81
Private surface 1§
Implementation details, listed for orientation only.
private const PREFIX = '__ztd_original_'Test cases 16§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
MutationRowIdentityTest::testColumnBuildsReservedMetadataColumnNamecovers and callsMutationRowIdentityTest::testExtractCarriesNoKeyWhereTheRowHasNoneOfItcovers and callsMutationRowIdentityTest::testExtractReadsAnUnchangedKeyAsItsOwnOldValuecovers and callsMutationRowIdentityTest::testExtractSplitsTheRowFromTheKeyItUsedToHavecovers and callsMutationRowIdentityTest::testFallsBackToCurrentKeyForLegacyProjectionscovers and callsMutationRowIdentityTest::testSeparatesOriginalCompositeKeyFromTheUpdatedRowcovers and callsMutationRowIdentityTest::testStripAllAnswersNothingForNoRowscovers and callsMutationRowIdentityTest::testStripAllTakesTheCarriedNamesOffEveryRowcovers and callsMutationRowIdentityTest::testStripRemovesEveryInternalIdentityColumncovers and calls
Other tests reaching this symbol 7
Relations§
Instantiated in 3
- new ZtdQuery\Shadow\Mutation\MutationImpact::__construct() packages/ztd-query-core/src/Shadow/Mutation/MutationImpact.php:42
- new ZtdQuery\Shadow\Mutation\Row\UpdateMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Row/UpdateMutation.php:84
- new ZtdQuery\Shadow\TableTransitions::__construct() packages/ztd-query-core/src/Shadow/TableTransitions.php:41
Method calls 4
- method-call ZtdQuery\Shadow\Mutation\MutationImpact::returningRows() packages/ztd-query-core/src/Shadow/Mutation/MutationImpact.php:82
- method-call ZtdQuery\Shadow\Mutation\MutationImpact::returningRows() packages/ztd-query-core/src/Shadow/Mutation/MutationImpact.php:85
- method-call ZtdQuery\Shadow\Mutation\Row\UpdateMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Row/UpdateMutation.php:87
- method-call ZtdQuery\Shadow\TableTransitions::pairByIdentity() packages/ztd-query-core/src/Shadow/TableTransitions.php:152