classCascadedChildren
final class CascadedChildren
The rows of one child table as a cascade leaves them.
Following a constraint reads the child rows once and then rewrites some and drops others, and the caller needs both the rows to write back and an account of what happened to them. Keeping the two together is what makes the account impossible to disagree with the rows.
Type Aliases§
Row = import from TableDefinitionMethods§
public function __construct(array<int, Row> $rows)Parameters
$rows | array<int, Row> | The child rows as they stood |
Test cases 6
CascadedChildrenTest::testAreUnchangedSaysWhetherTheCascadeReachedTheTableAtAllcoversCascadedChildrenTest::testDeletedAnswersNothingWhereNoRowWentcoversCascadedChildrenTest::testRemoveDropsThoseRowsAndKeepsTheRestInOrdercoversCascadedChildrenTest::testReplaceWritesTheRowAndRecordsWhatItWascoversCascadedChildrenTest::testRowsAnswersWhatTheCascadeWasGivenWhereItReachedNothingcoversCascadedChildrenTest::testUpdatedAnswersNothingWhereNoRowChangedcovers
public function rows(): array<int, Row>Answers the child rows as they stand.
Returns
array<int, Row> The rowsTest cases 6
CascadedChildrenTest::testRemoveDropsThoseRowsAndKeepsTheRestInOrdercovers and callsCascadedChildrenTest::testReplaceWritesTheRowAndRecordsWhatItWascovers and callsCascadedChildrenTest::testRowsAnswersWhatTheCascadeWasGivenWhereItReachedNothingcovers and callsForeignKeyCascadeTest::testCarryDeleteDropsEveryChildThatWasHoldingTheKeyWhereTheActionCascadescallsForeignKeyCascadeTest::testCarryDeleteSetsTheKeyToNullWhereTheActionSaysToRatherThanDroppingTheRowcallsForeignKeyCascadeTest::testCarryUpdateWritesTheNewKeyIntoEveryChildThatWasHoldingTheOldOnecalls
Called from 3
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:84
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:120
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:155
public function replace(int $index, Row $row): voidWrites a row over the one in that position, and records the change.
Parameters
$index | int | Position of the row being written over |
$row | Row | The row as it should now be |
Test cases 1
CascadedChildrenTest::testReplaceWritesTheRowAndRecordsWhatItWascovers and calls
Called from 2
public function remove(list<int> $indexes): voidDrops the rows in those positions, and records that they went.
Parameters
$indexes | list<int> | Positions of the rows that went |
Test cases 2
Called from 1
public function deleted(): list<Row>public function updated(): list<RowChange>Answers what happened to the rows that stayed.
Returns
list<RowChange> The changesTest cases 2
CascadedChildrenTest::testReplaceWritesTheRowAndRecordsWhatItWascovers and callsCascadedChildrenTest::testUpdatedAnswersNothingWhereNoRowChangedcovers and calls
Called from 1
public function areUnchanged(): boolReports whether the cascade reached this table at all.
Returns
bool True when nothing went and nothing changedTest cases 3
Called from 1
Private surface 3§
Implementation details, listed for orientation only.
private RowSet $rowsprivate RowSet $deletedprivate list<RowChange> $updated = []Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
CascadedChildrenTest::testAreUnchangedSaysWhetherTheCascadeReachedTheTableAtAllcovers and callsCascadedChildrenTest::testDeletedAnswersNothingWhereNoRowWentcovers and callsCascadedChildrenTest::testRemoveDropsThoseRowsAndKeepsTheRestInOrdercovers and callsCascadedChildrenTest::testReplaceWritesTheRowAndRecordsWhatItWascovers and callsCascadedChildrenTest::testRowsAnswersWhatTheCascadeWasGivenWhereItReachedNothingcovers and callsCascadedChildrenTest::testUpdatedAnswersNothingWhereNoRowChangedcovers and calls
Other tests reaching this symbol 6
ForeignKeyCascadeTest::testCarryDeleteDropsEveryChildThatWasHoldingTheKeyWhereTheActionCascadescallsForeignKeyCascadeTest::testCarryDeleteReachesNothingWhereTheParentTableStillHoldsTheKeycallsForeignKeyCascadeTest::testCarryDeleteSetsTheKeyToNullWhereTheActionSaysToRatherThanDroppingTheRowcallsForeignKeyCascadeTest::testCarryUpdateReachesNothingWhereTheParentTableStillHoldsTheOldKeycallsForeignKeyCascadeTest::testCarryUpdateWritesTheNewKeyIntoEveryChildThatWasHoldingTheOldOnecallsReferentialIntegrityEnforcerTestcalls
Relations§
Instantiated in 1
Method calls 9
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:80
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:84
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:86
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:86
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:120
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryUpdate() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:124
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:155
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:163
- method-call ZtdQuery\Shadow\ForeignKeyCascade::carryDelete() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:165