classDuplicateKeyException
final class DuplicateKeyException<TValue>
extends SimulationException
Exception thrown when a PRIMARY KEY or UNIQUE constraint is violated.
A refusal says what it is about without naming the schema it came from, so the key values it carries are spelled out here rather than imported.
Type Aliases§
KeyValues = array<string, TValue>Methods§
public function __construct(
string $sql,
string $tableName,
string $keyName,
KeyValues $keyValues = [],
)Parameters
$sql | string | The SQL statement. |
$tableName | string | The name of the table. |
$keyName | string | The name of the key constraint. |
$keyValues | KeyValues | The duplicate key values. |
Calls 4
- static-call DuplicateKeyException::formatKeyValue() line 52
- function-call
implodeline 54 - static-call SimulationException::__construct() line 55
- function-call
sprintfline 55
public function getSql(): stringGet the SQL statement.
Returns
stringTest cases 1
public function getTableName(): stringGet the name of the table.
Returns
stringTest cases 1
public function getKeyName(): stringGet the name of the key constraint.
Returns
stringTest cases 1
public function getKeyValues(): KeyValuesGet the duplicate key values.
Returns
Test cases 1
public static function formatKeyValue(mixed $value): stringFormats a duplicate value without coercing the value stored in the exception.
Parameters
$value | mixed |
Returns
stringTest cases 1
Called from 1
Private surface 4§
Implementation details, listed for orientation only.
private string $sqlprivate string $tableNameprivate string $keyNameprivate KeyValues $keyValuesTest cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
DuplicateKeyExceptionTest::testFormatKeyValueKeepsErrorMessagesReadableForDriverValuescallsDuplicateKeyExceptionTest::testGetKeyNameReturnsKeyNamecallsDuplicateKeyExceptionTest::testGetKeyValuesReturnsKeyValuescallsDuplicateKeyExceptionTest::testGetMessageReturnsFormattedMessagecallsDuplicateKeyExceptionTest::testGetMessageWithEmptyKeyValuescallsDuplicateKeyExceptionTest::testGetMessageWithMultipleKeyValuescallsDuplicateKeyExceptionTest::testGetMessageWithNullKeyValuecallsDuplicateKeyExceptionTest::testGetMessageWithStringKeyValuecallsDuplicateKeyExceptionTest::testGetSqlReturnsOriginalSqlcallsDuplicateKeyExceptionTest::testGetTableNameReturnsTableNamecalls
Other tests reaching this symbol 7
ExecutionCheck::verifycallsInsertMutationTest::testValidatePrimaryKeyDuplicateThrowsExceptioncallsInsertMutationTest::testValidateUniqueThrowsExceptioncallsUpdateMutationTest::testValidateUniqueThrowsExceptioncallsRowConstraintsTest::testAssertNoDuplicateUniqueKeyRefusesARowCollidingWithOneAlreadyTherecallsSynchronizeMutationTest::testApplyRejectsDuplicateCandidateKeyscallsShadowApplicationTestcalls
Relations§
Instantiated in 3
- new ZtdQuery\Shadow\Mutation\Row\InsertMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Row/InsertMutation.php:119
- new ZtdQuery\Shadow\Mutation\RowConstraints::assertNoDuplicateUniqueKey() packages/ztd-query-core/src/Shadow/Mutation/RowConstraints.php:90
- new ZtdQuery\Shadow\Mutation\Table\SynchronizeMutation::apply() packages/ztd-query-core/src/Shadow/Mutation/Table/SynchronizeMutation.php:59