classUpsertMutationRow
final class UpsertMutationRow
Names the columns an UPSERT carries its assignment values under.
The rewritten statement works out, per row, whether the conflict clause applied and what each assignment came to, and reads both back alongside the row. Those columns are carried under names no table would use, and taken off again before the row is handed to the caller.
Type Aliases§
Row = import from TableDefinitionMethods§
public function valueColumn(int $index): stringAnswers the name one assignment's value is carried under.
Parameters
$index | int | Position of the assignment in the conflict clause |
Returns
string Name no table would useTest cases 11
UpsertMutationRowTest::testIncomingRowLeavesACarriedValueTheClauseNeverDeclaredcoversUpsertMutationRowTest::testIncomingRowLeavesOnlyWhatTheStatementActuallyWrotecoversUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcovers and callsUpsertMutationRowTest::testValueColumnNamesOneAssignmentSoNoTableCouldUseTheNamecovers and callsUpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertMutationTest::testDatabaseEvaluatedBatchDetectsConflictsWithRowsInsertedEarlierInStatementcallsUpsertMutationTest::testDatabaseEvaluatedBatchReevaluatesAgainstLatestConflictRowcallsUpsertMutationTest::testDatabaseEvaluatedBatchRejectsStaleUnsupportedExpressioncallsUpsertMutationTest::testDatabaseEvaluatedPredicateFallsBackWhenMetadataIsMissingcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcallsUpsertUpdateTest::testWithColumnTakesWhatTheDatabaseWorkedOutcalls
Called from 2
Calls 1
- class-const UpsertMutationRow::VALUE_PREFIX() line 34
public function predicateColumn(): stringAnswers the name the conflict-clause verdict is carried under.
Returns
string Name no table would useTest cases 4
UpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcovers and callsUpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertUpdateTest::testAppliesTakesTheVerdictTheDatabaseWorkedOutcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcalls
Called from 2
Calls 1
- class-const UpsertMutationRow::PREDICATE() line 44
public function predicateMatches(mixed $value): boolReports whether the verdict a driver read back means the clause applied.
Every driver spells truth differently — a boolean, a one, the text of a one, or Postgres\'s single t — and all four mean the same thing here.
Parameters
$value | mixed | Verdict as the driver read it back |
Returns
bool True when the conflict clause appliedTest cases 8
UpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValuescallsUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#boolean falsecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#boolean truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#integer falsecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#integer truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#nullcoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#numeric string truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#PostgreSQL truecovers
Takes the carried columns off a row, leaving the row the statement wrote.
Parameters
$row | Row | Row as the rewritten statement read it back |
$valueCount | int | How many assignments the conflict clause declares |
Returns
Row The row as the caller should see itTest cases 3
UpsertMutationRowTest::testIncomingRowLeavesACarriedValueTheClauseNeverDeclaredcovers and callsUpsertMutationRowTest::testIncomingRowLeavesOnlyWhatTheStatementActuallyWrotecovers and callsUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcovers and calls
Called from 1
Calls 2
- method-call UpsertMutationRow::valueColumn() line 73
- class-const UpsertMutationRow::PREDICATE() line 75
Private surface 2§
Implementation details, listed for orientation only.
private const VALUE_PREFIX = '__ztd_upsert_value_'private const PREDICATE = '__ztd_upsert_predicate'Test cases 20§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 12
UpsertMutationRowTest::testIncomingRowLeavesACarriedValueTheClauseNeverDeclaredcovers and callsUpsertMutationRowTest::testIncomingRowLeavesOnlyWhatTheStatementActuallyWrotecovers and callsUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcovers and callsUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValuescallsUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#boolean falsecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#boolean truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#integer falsecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#integer truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#nullcoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#numeric string truecoversUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValues#PostgreSQL truecoversUpsertMutationRowTest::testValueColumnNamesOneAssignmentSoNoTableCouldUseTheNamecovers and calls
Other tests reaching this symbol 8
UpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertMutationTest::testDatabaseEvaluatedBatchDetectsConflictsWithRowsInsertedEarlierInStatementcallsUpsertMutationTest::testDatabaseEvaluatedBatchReevaluatesAgainstLatestConflictRowcallsUpsertMutationTest::testDatabaseEvaluatedBatchRejectsStaleUnsupportedExpressioncallsUpsertMutationTest::testDatabaseEvaluatedPredicateFallsBackWhenMetadataIsMissingcallsUpsertUpdateTest::testAppliesTakesTheVerdictTheDatabaseWorkedOutcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcallsUpsertUpdateTest::testWithColumnTakesWhatTheDatabaseWorkedOutcalls
Relations§
Instantiated in 1
Method calls 5
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::incomingRow() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:59
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::applies() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:85
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::applies() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:86
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::applies() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:86
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::withColumn() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:167