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 4
Called from 4
- method-call ZtdQuery\Shadow\Mutation\MutationRowIdentity::extract() packages/ztd-query-core/src/Shadow/Mutation/MutationRowIdentity.php:80
- method-call ZtdQuery\Platform\MySql\Rewrite\Transformer\Update\ResultSelect::selectColumns() packages/ztd-query-mysql/src/Rewrite/Transformer/Update/ResultSelect.php:119
- method-call ZtdQuery\Platform\Postgres\Rewrite\Transformer\Update\ColumnProjection::render() packages/ztd-query-postgres/src/Rewrite/Transformer/Update/ColumnProjection.php:40
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Transformer\UpdateTransformer::buildProjection() packages/ztd-query-sqlite/src/Rewrite/Transformer/UpdateTransformer.php:103
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 1
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
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::testExtractCarriesNoKeyWhereTheRowHasNoneOfItcallsMutationRowIdentityTest::testExtractReadsAnUnchangedKeyAsItsOwnOldValuecallsMutationRowIdentityTest::testExtractSplitsTheRowFromTheKeyItUsedToHavecallsMutationRowIdentityTest::testFallsBackToCurrentKeyForLegacyProjectionscallsMutationRowIdentityTest::testSeparatesOriginalCompositeKeyFromTheUpdatedRowcalls
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 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
MutationRowIdentityTest::testColumnBuildsReservedMetadataColumnNamecallsMutationRowIdentityTest::testExtractCarriesNoKeyWhereTheRowHasNoneOfItcallsMutationRowIdentityTest::testExtractReadsAnUnchangedKeyAsItsOwnOldValuecallsMutationRowIdentityTest::testExtractSplitsTheRowFromTheKeyItUsedToHavecallsMutationRowIdentityTest::testFallsBackToCurrentKeyForLegacyProjectionscallsMutationRowIdentityTest::testSeparatesOriginalCompositeKeyFromTheUpdatedRowcallsMutationRowIdentityTest::testStripAllAnswersNothingForNoRowscallsMutationRowIdentityTest::testStripAllTakesTheCarriedNamesOffEveryRowcallsMutationRowIdentityTest::testStripRemovesEveryInternalIdentityColumncalls
Other tests reaching this symbol 8
ResultSelectTest::testSelectColumnscallsSessionTestcallsMutationImpactTestcallsUpdateMutationTestcallsShadowMutationTestcallsReferentialIntegrityEnforcerTestcallsTableTransitionsTest::testPairByIdentityLeavesARowNoResultRowSpeaksForcallsTableTransitionsTest::testPairByIdentityTakesThePairsAnUpdateToldUsAboutcalls
Relations§
Instantiated in 6
- 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
- new ZtdQuery\Platform\MySql\Rewrite\Transformer\Update\ResultSelect::selectColumns() packages/ztd-query-mysql/src/Rewrite/Transformer/Update/ResultSelect.php:117
- new ZtdQuery\Platform\Postgres\Rewrite\Transformer\Update\ColumnProjection::render() packages/ztd-query-postgres/src/Rewrite/Transformer/Update/ColumnProjection.php:38
- new ZtdQuery\Platform\Sqlite\Rewrite\Transformer\UpdateTransformer::buildProjection() packages/ztd-query-sqlite/src/Rewrite/Transformer/UpdateTransformer.php:101
Method calls 7
- 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
- method-call ZtdQuery\Platform\MySql\Rewrite\Transformer\Update\ResultSelect::selectColumns() packages/ztd-query-mysql/src/Rewrite/Transformer/Update/ResultSelect.php:119
- method-call ZtdQuery\Platform\Postgres\Rewrite\Transformer\Update\ColumnProjection::render() packages/ztd-query-postgres/src/Rewrite/Transformer/Update/ColumnProjection.php:40
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Transformer\UpdateTransformer::buildProjection() packages/ztd-query-sqlite/src/Rewrite/Transformer/UpdateTransformer.php:103