classInsertMutation
final class InsertMutation
implements DataMutation
Applies INSERT result rows to the shadow store.
Type Aliases§
Row = import from TableDefinitionMethods§
public function __construct(
string $tableName,
array<int, string> $primaryKeys = [],
bool $ignore = false,
TableDefinition|null $tableDefinition = null,
string $sql = '',
bool $validateConstraints = false,
CandidateKeySet|null $candidateKeys = null,
UpsertExpression|null $conflictPredicate = null,
)Parameters
$tableName | string | Target table. |
$primaryKeys | array<int, string> | Primary key columns. |
$ignore | bool | Whether to ignore duplicates (INSERT IGNORE). |
$tableDefinition | TableDefinition|null | Table definition for constraint validation. |
$sql | string | Original SQL statement for exception messages. |
$validateConstraints | bool | Whether to validate constraints. |
$candidateKeys | CandidateKeySet|null | Candidate keys used for duplicate detection. |
$conflictPredicate | UpsertExpression|null | Condition that controls candidate-key eligibility. |
Test cases 20
InsertMutationTest::testApplyInsertsMultipleRowscoversInsertMutationTest::testApplyInsertsToEmptyTablecoversInsertMutationTest::testApplyWithCompositePrimaryKeycoversInsertMutationTest::testInsertIgnoreSkipsDuplicatescoversInsertMutationTest::testInsertIgnoreSkipsUniqueKeyConflictcoversInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecoversInsertMutationTest::testTableNameApplyAppendsRowscoversInsertMutationTest::testUniqueConstraintAllowsNullcoversInsertMutationTest::testValidateNotNullThrowsExceptioncoversInsertMutationTest::testValidatePrimaryKeyDuplicateThrowsExceptioncoversInsertMutationTest::testValidateUniqueThrowsExceptioncoversInsertMutationTest::testValidationDisabledByDefaultAllowsDuplicatescoversShadowMutationTest::testApplyWritesWhatTheStatementDidIntoTheShadowcoversShadowMutationTest::testInsertIncreasesRowCountcoversShadowMutationTest::testInsertIntoEmptyTablecoversShadowMutationTest::testInsertWithEmptyStringValuescoversShadowMutationTest::testInsertWithNullValuescoversShadowMutationTest::testMutationTableIsolationcoversShadowMutationTest::testTableNameAnswersTheTableTheStatementWritescoversShadowMutationTest::testTableNameIsConsistentcovers
Calls 3
- static-call CandidateKeySet::fromSchema() line 91
- new RowConstraints line 93
- new ConflictSearch line 94
public function apply(ShadowStore $store, array $rows): void{@inheritDoc}
Parameters
$store | ShadowStore | |
$rows | array |
Throws
DuplicateKeyException When a row would collide with one already there on a candidate keyTest cases 27
MutationContractTest::testInsertIncreasesRowCountcallsMutationContractTest::testInsertIntoEmptyTablecallsMutationContractTest::testInsertWithEmptyStringValuescallsMutationContractTest::testInsertWithNullValuescallsMutationContractTest::testMutationTableIsolationcallsInsertMutationTest::testApplyInsertsMultipleRowscovers and callsInsertMutationTest::testApplyInsertsToEmptyTablecovers and callsInsertMutationTest::testApplyWithCompositePrimaryKeycovers and callsInsertMutationTest::testInsertIgnoreSkipsDuplicatescovers and callsInsertMutationTest::testInsertIgnoreSkipsUniqueKeyConflictcovers and callsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecovers and callsInsertMutationTest::testTableNameApplyAppendsRowscovers and callsInsertMutationTest::testUniqueConstraintAllowsNullcovers and callsInsertMutationTest::testValidateNotNullThrowsExceptioncovers and callsInsertMutationTest::testValidatePrimaryKeyDuplicateThrowsExceptioncovers and callsInsertMutationTest::testValidateUniqueThrowsExceptioncovers and callsInsertMutationTest::testValidationDisabledByDefaultAllowsDuplicatescovers and callsShadowMutationTest::testApplyWritesWhatTheStatementDidIntoTheShadowcovers and callsShadowMutationTest::testInsertIncreasesRowCountcoversShadowMutationTest::testInsertIntoEmptyTablecoversShadowMutationTest::testInsertWithEmptyStringValuescoversShadowMutationTest::testInsertWithNullValuescoversShadowMutationTest::testMutationTableIsolationcoversReferentialIntegrityEnforcerTest::testAcceptsExplicitReferenceToNonPrimaryCandidateKeycallsReferentialIntegrityEnforcerTest::testExplicitReferencedColumnsAreNotReplacedByPrimaryKeycallsReferentialIntegrityEnforcerTest::testRejectsInsertWhoseParentDoesNotExistcallsReferentialIntegrityEnforcerTest::testValidationContinuesPastMissingAndNullForeignKeyscalls
Calls 6
- method-call ShadowStore::get() line 104
- method-call RowConstraints::assertNoNullWhereNoneIsAllowed() line 109
- method-call ConflictSearch::of() line 112
- new DuplicateKeyException line 119
- method-call RowConstraints::assertNoDuplicateUniqueKey() line 129
- method-call ShadowStore::insert() line 136
public function tableName(): string{@inheritDoc}
Returns
stringTest cases 4
Private surface 9§
Implementation details, listed for orientation only.
private string $tableNameprivate bool $ignoreprivate TableDefinition|null $tableDefinitionprivate string $sqlprivate bool $validateConstraintsprivate CandidateKeySet $candidateKeysprivate ?UpsertExpression $conflictPredicateprivate RowConstraints $constraintsprivate ConflictSearch $conflictsTest cases 55§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 12
InsertMutationTest::testApplyInsertsMultipleRowscovers and callsInsertMutationTest::testApplyInsertsToEmptyTablecovers and callsInsertMutationTest::testApplyWithCompositePrimaryKeycovers and callsInsertMutationTest::testInsertIgnoreSkipsDuplicatescovers and callsInsertMutationTest::testInsertIgnoreSkipsUniqueKeyConflictcovers and callsInsertMutationTest::testInsertIgnoreUsesPartialConflictPredicatecovers and callsInsertMutationTest::testTableNameApplyAppendsRowscovers and callsInsertMutationTest::testUniqueConstraintAllowsNullcovers and callsInsertMutationTest::testValidateNotNullThrowsExceptioncovers and callsInsertMutationTest::testValidatePrimaryKeyDuplicateThrowsExceptioncovers and callsInsertMutationTest::testValidateUniqueThrowsExceptioncovers and callsInsertMutationTest::testValidationDisabledByDefaultAllowsDuplicatescovers and calls
Other tests reaching this symbol 43
MutationContractTest::testInsertIncreasesRowCountcallsMutationContractTest::testInsertIntoEmptyTablecallsMutationContractTest::testInsertWithEmptyStringValuescallsMutationContractTest::testInsertWithNullValuescallsMutationContractTest::testMutationTableIsolationcallsMutationContractTest::testTableNameIsConsistentcallsRewriterContractTest::testInsertReturnsWriteSimulatedWithMutationcallsRewriterContractTest::testWritePlanHasNonNullMutationcallsFakeSqlRewriter::rewriteInsertcallsRewritePlanTest::testAffectedRowsModeReturningProjectionAffectedRowsModePlanCarriesReturningAndAffectedRowsMetadatacallsRewritePlanTest::testKindSqlKindPlanHoldsSqlKindAndMutationcallsRewritePlanTest::testRequireMutationAnswersTheMutationTheWriteWasSimulatedAscallsSessionTest::testApplyShadowWritesTheMutationAndAnswersWhatItCameTocallsSessionTest::testForeignKeyFailureRestoresShadowStatecallsSessionTest::testRunResultSelectAndApplyShadowReadsBackWhatTheStatementWouldHaveWrittencallsDataMutationTest::providerRowChangingMutationcallsMutationImpactTest::testAffectedRowCountIsNothingWhereTheStatementReportsNonecallsMutationImpactTest::testIgnoredInsertHasNoReturningRowscallsMutationImpactTest::testImpactPreservesEveryChangedRowAndDuplicateMultiplicitycallsMutationImpactTest::testInsertImpactContainsOnlyRowsActuallyAddedcallsMutationImpactTest::testReturningRowsAnswersTheRowsAStatementWouldReadBackcallsShadowMutationTest::testApplyWritesWhatTheStatementDidIntoTheShadowcovers and callsShadowMutationTest::testInsertIncreasesRowCountcoversShadowMutationTest::testInsertIntoEmptyTablecoversShadowMutationTest::testInsertWithEmptyStringValuescoversShadowMutationTest::testInsertWithNullValuescoversShadowMutationTest::testMutationTableIsolationcoversShadowMutationTest::testTableNameAnswersTheTableTheStatementWritescovers and callsShadowMutationTest::testTableNameIsConsistentcoversReferentialIntegrityEnforcerTest::testAcceptsExplicitReferenceToNonPrimaryCandidateKeycallsReferentialIntegrityEnforcerTest::testExplicitReferencedColumnsAreNotReplacedByPrimaryKeycallsReferentialIntegrityEnforcerTest::testFallbackTransitionPropagatesUpdateAndDeleteFromOneTablecallsReferentialIntegrityEnforcerTest::testMissingReferencedValuesDoNotStopLaterUpdateOrDeleteCascadescallsReferentialIntegrityEnforcerTest::testRejectsInsertWhoseParentDoesNotExistcallsReferentialIntegrityEnforcerTest::testRowsWithMissingPrimaryKeyCannotMatchRowsThatHaveTheKeycallsReferentialIntegrityEnforcerTest::testValidationContinuesPastMissingAndNullForeignKeyscallsShadowApplicationTest::testApplyAnswersWhatTheStatementCameTocallsShadowApplicationTest::testApplyLeavesTheShadowAsItWasWhenTheStatementIsRefusedcallsShadowApplicationTest::testApplyWritesTheRowsAMutationDescribesIntoTheShadowcallsShadowApplicationTest::testLastInsertIdOfAnswersTheIdentityTheTableSaysIsNumberedcallsShadowApplicationTest::testLastInsertIdOfFallsBackToASingleColumnKeycallsShadowApplicationTest::testLastInsertIdOfIsNothingWhereNoColumnIsNumberedcallsStatementSimulatorTest::testWriteStatementUpdatesShadowStorecalls
Relations§
Constant reads 1
- class-const packages/ztd-query-core/src/Compatibility/ClassAliases.php packages/ztd-query-core/src/Compatibility/ClassAliases.php:19