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 10
MetadataColumnsTest::testRendercallsUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcallsUpsertMutationRowTest::testValueColumnNamesOneAssignmentSoNoTableCouldUseTheNamecallsUpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertMutationTest::testDatabaseEvaluatedBatchDetectsConflictsWithRowsInsertedEarlierInStatementcallsUpsertMutationTest::testDatabaseEvaluatedBatchReevaluatesAgainstLatestConflictRowcallsUpsertMutationTest::testDatabaseEvaluatedBatchRejectsStaleUnsupportedExpressioncallsUpsertMutationTest::testDatabaseEvaluatedPredicateFallsBackWhenMetadataIsMissingcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcallsUpsertUpdateTest::testWithColumnTakesWhatTheDatabaseWorkedOutcalls
Called from 5
- method-call ZtdQuery\Shadow\Mutation\UpsertMutationRow::incomingRow() packages/ztd-query-core/src/Shadow/Mutation/UpsertMutationRow.php:73
- method-call ZtdQuery\Shadow\Mutation\UpsertUpdate::withColumn() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:167
- method-call ZtdQuery\Platform\MySql\Rewrite\Upsert\MetadataColumns::render() packages/ztd-query-mysql/src/Rewrite/Upsert/MetadataColumns.php:42
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:70
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Upsert\SqliteNativeUpsertProjector::project() packages/ztd-query-sqlite/src/Rewrite/Upsert/SqliteNativeUpsertProjector.php:72
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 5
MetadataColumnsTest::testRendercallsUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcallsUpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertUpdateTest::testAppliesTakesTheVerdictTheDatabaseWorkedOutcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcalls
Called from 5
- 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\Platform\MySql\Rewrite\Upsert\MetadataColumns::render() packages/ztd-query-mysql/src/Rewrite/Upsert/MetadataColumns.php:52
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:75
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Upsert\SqliteNativeUpsertProjector::project() packages/ztd-query-sqlite/src/Rewrite/Upsert/SqliteNativeUpsertProjector.php:77
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 appliedTakes 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
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 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
UpsertMutationRowTest::testIncomingRowLeavesACarriedValueTheClauseNeverDeclaredcallsUpsertMutationRowTest::testIncomingRowLeavesOnlyWhatTheStatementActuallyWrotecallsUpsertMutationRowTest::testPredicateColumnAndValueColumnNameWhatTheStatementCarriesAlongsideARowcallsUpsertMutationRowTest::testPredicateMatchesNormalizesDatabasePredicateValuescallsUpsertMutationRowTest::testValueColumnNamesOneAssignmentSoNoTableCouldUseTheNamecalls
Other tests reaching this symbol 9
MetadataColumnsTest::testRendercallsUpsertMutationTest::testApplyUsesDatabaseEvaluatedValuesAndStripsMetadatacallsUpsertMutationTest::testDatabaseEvaluatedBatchDetectsConflictsWithRowsInsertedEarlierInStatementcallsUpsertMutationTest::testDatabaseEvaluatedBatchReevaluatesAgainstLatestConflictRowcallsUpsertMutationTest::testDatabaseEvaluatedBatchRejectsStaleUnsupportedExpressioncallsUpsertMutationTest::testDatabaseEvaluatedPredicateFallsBackWhenMetadataIsMissingcallsUpsertUpdateTest::testAppliesTakesTheVerdictTheDatabaseWorkedOutcallsUpsertUpdateTest::testIncomingRowTakesOffWhatTheDatabaseWorkedOutcallsUpsertUpdateTest::testWithColumnTakesWhatTheDatabaseWorkedOutcalls
Relations§
Instantiated in 4
- new ZtdQuery\Shadow\Mutation\UpsertUpdate::__construct() packages/ztd-query-core/src/Shadow/Mutation/UpsertUpdate.php:45
- new ZtdQuery\Platform\MySql\Rewrite\Upsert\MetadataColumns::render() packages/ztd-query-mysql/src/Rewrite/Upsert/MetadataColumns.php:34
- new ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:67
- new ZtdQuery\Platform\Sqlite\Rewrite\Upsert\SqliteNativeUpsertProjector::project() packages/ztd-query-sqlite/src/Rewrite/Upsert/SqliteNativeUpsertProjector.php:69
Method calls 11
- 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
- method-call ZtdQuery\Platform\MySql\Rewrite\Upsert\MetadataColumns::render() packages/ztd-query-mysql/src/Rewrite/Upsert/MetadataColumns.php:42
- method-call ZtdQuery\Platform\MySql\Rewrite\Upsert\MetadataColumns::render() packages/ztd-query-mysql/src/Rewrite/Upsert/MetadataColumns.php:52
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:70
- method-call ZtdQuery\Platform\Postgres\Rewrite\Upsert\PgSqlNativeUpsertProjector::project() packages/ztd-query-postgres/src/Rewrite/Upsert/PgSqlNativeUpsertProjector.php:75
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Upsert\SqliteNativeUpsertProjector::project() packages/ztd-query-sqlite/src/Rewrite/Upsert/SqliteNativeUpsertProjector.php:72
- method-call ZtdQuery\Platform\Sqlite\Rewrite\Upsert\SqliteNativeUpsertProjector::project() packages/ztd-query-sqlite/src/Rewrite/Upsert/SqliteNativeUpsertProjector.php:77