classRewritePlan
final class RewritePlan
Represents the rewrite outcome for a single SQL statement.
Methods§
public function __construct(
string $sql,
QueryKind $kind,
ShadowMutation|null $mutation = null,
ReturningProjection|null $returningProjection = null,
AffectedRowsMode $affectedRowsMode = AffectedRowsMode::Changed,
)Parameters
$sql | string | Rewritten SQL. |
$kind | QueryKind | Classified kind of the statement. |
$mutation | ShadowMutation|null | Optional mutation to apply after execution. |
$returningProjection | ReturningProjection|null | Optional client-visible write projection. |
$affectedRowsMode | AffectedRowsMode | Observable affected-row convention. |
Test cases 7
RewritePlanTest::testAffectedRowsModeReturningProjectionAffectedRowsModePlanCarriesReturningAndAffectedRowsMetadatacoversRewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcoversRewritePlanTest::testMutationPlanWithoutMutationcoversRewritePlanTest::testRequireMutationAnswersTheMutationTheWriteWasSimulatedAscoversRewritePlanTest::testRequireMutationRefusesAPlanThatCarriesNonecoversRewritePlanTest::testReturningProjectionIsNothingWherePlanCarriesNonecoversRewritePlanTest::testSqlKeepsTheStatementThePlanIsForcovers
Calls 1
- class-const AffectedRowsMode::Changed() line 52
public function sql(): stringGet rewritten SQL.
Returns
stringTest cases 2
RewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcovers and callsRewritePlanTest::testSqlKeepsTheStatementThePlanIsForcovers and calls
Called from 3
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:355
- method-call ZtdQuery\Session::runResultSelectAndApplyShadow() packages/ztd-query-core/src/Session.php:387
- method-call ZtdQuery\Session::runResultSelectAndApplyShadow() packages/ztd-query-core/src/Session.php:391
public function kind(): QueryKindGet statement kind for routing decisions.
Returns
Test cases 1
RewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcovers and calls
Called from 4
- method-call ZtdQuery\Session::shouldExecute() packages/ztd-query-core/src/Session.php:137
- method-call ZtdQuery\Session::needsPostProcessing() packages/ztd-query-core/src/Session.php:145
- method-call ZtdQuery\Session::needsPostProcessing() packages/ztd-query-core/src/Session.php:146
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:347
public function mutation(): ?ShadowMutationGet the mutation for write simulation, if any.
Returns
Test cases 2
RewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcovers and callsRewritePlanTest::testMutationPlanWithoutMutationcovers and calls
public function requireMutation(): ShadowMutationAnswers the mutation a simulated write must carry.
A plan whose kind says the write was simulated and that carries no mutation describes nothing the shadow could be told, so the statement is refused rather than read back as though it had been simulated.
Returns
ShadowMutation The mutationThrows
RuntimeException When the plan carries noneTest cases 2
Called from 2
Calls 1
- new
RuntimeExceptionline 99
public function returningProjection(): ?ReturningProjectionReturning projection.
Returns
Test cases 2
Called from 1
public function affectedRowsMode(): AffectedRowsModeAffected rows mode.
Returns
Test cases 1
Called from 1
Private surface 5§
Implementation details, listed for orientation only.
private string $sqlprivate QueryKind $kindprivate ShadowMutation|null $mutationprivate ?ReturningProjection $returningProjectionprivate AffectedRowsMode $affectedRowsModeTest cases 32§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
RewritePlanTest::testAffectedRowsModeReturningProjectionAffectedRowsModePlanCarriesReturningAndAffectedRowsMetadatacovers and callsRewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcovers and callsRewritePlanTest::testMutationPlanWithoutMutationcovers and callsRewritePlanTest::testRequireMutationAnswersTheMutationTheWriteWasSimulatedAscovers and callsRewritePlanTest::testRequireMutationRefusesAPlanThatCarriesNonecovers and callsRewritePlanTest::testReturningProjectionIsNothingWherePlanCarriesNonecovers and callsRewritePlanTest::testSqlKeepsTheStatementThePlanIsForcovers and calls
Other tests reaching this symbol 25
ExceptionThrowingRewritercallsFakeSqlRewriter::rewritecallsFakeSqlRewriter::rewriteDdlcallsFakeSqlRewriter::rewriteDeletecallsFakeSqlRewriter::rewriteInsertcallsFakeSqlRewriter::rewriteSelectcallsFakeSqlRewriter::rewriteTruncatecallsFakeSqlRewriter::rewriteUpdatecallsFixedRewritercallsMultiRewritePlanTest::testCountReturnsNumberOfPlanscallsMultiRewritePlanTest::testFirstReturnsFirstPlancallsMultiRewritePlanTest::testGetReturnsNullForInvalidIndexcallsMultiRewritePlanTest::testGetReturnsPlanAtIndexcallsMultiRewritePlanTest::testPlansReturnsAllPlanscallsRewriteRefusalTestcallsSessionTest::testForeignKeyFailureRestoresShadowStatecallsSessionTest::testMutationFailureIsConvertedToDatabaseExceptioncallsSessionTest::testNeedsPostProcessingIsTrueForTheKindsThatChangeTheShadowcallsSessionTest::testProcessExecutedStatementReadsAReadStatementStraightBackcallsSessionTest::testRunResultSelectAndApplyShadowReadsBackWhatTheStatementWouldHaveWrittencallsSessionTest::testShouldExecuteIsFalseOnlyForAPlanNothingIsToBeRunForcallsStatementSimulatorTest::testReadStatementReturnsFalseWhenExecutorFailscallsStatementSimulatorTest::testReadStatementReturnsRowCountcallsStatementSimulatorTest::testSimulateRefusesAWriteThePlanCarriesNoMutationForcallsStatementSimulatorTest::testWriteStatementUpdatesShadowStorecalls
Relations§
Instantiated in 3
Method calls 11
- method-call ZtdQuery\Session::shouldExecute() packages/ztd-query-core/src/Session.php:137
- method-call ZtdQuery\Session::needsPostProcessing() packages/ztd-query-core/src/Session.php:145
- method-call ZtdQuery\Session::needsPostProcessing() packages/ztd-query-core/src/Session.php:146
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:347
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:354
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:355
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:356
- method-call ZtdQuery\Session::processExecutedStatement() packages/ztd-query-core/src/Session.php:364
- method-call ZtdQuery\Session::runResultSelectAndApplyShadow() packages/ztd-query-core/src/Session.php:384
- method-call ZtdQuery\Session::runResultSelectAndApplyShadow() packages/ztd-query-core/src/Session.php:387
- method-call ZtdQuery\Session::runResultSelectAndApplyShadow() packages/ztd-query-core/src/Session.php:391
Type declarations 10
- type ZtdQuery\Rewrite\MultiRewritePlan packages/ztd-query-core/src/Rewrite/MultiRewritePlan.php:48
- type ZtdQuery\Rewrite\MultiRewritePlan packages/ztd-query-core/src/Rewrite/MultiRewritePlan.php:56
- type ZtdQuery\Rewrite\SqlRewriter packages/ztd-query-core/src/Rewrite/SqlRewriter.php:62
- type ZtdQuery\RewriteRefusal packages/ztd-query-core/src/RewriteRefusal.php:45
- type ZtdQuery\RewriteRefusal packages/ztd-query-core/src/RewriteRefusal.php:69
- type ZtdQuery\Session packages/ztd-query-core/src/Session.php:135
- type ZtdQuery\Session packages/ztd-query-core/src/Session.php:143
- type ZtdQuery\Session packages/ztd-query-core/src/Session.php:314
- type ZtdQuery\Session packages/ztd-query-core/src/Session.php:345
- type ZtdQuery\Session packages/ztd-query-core/src/Session.php:382