classSynchronizeMutation
final class SynchronizeMutation
implements DataMutation
Replaces a table with a database-evaluated complete result set.
Type Aliases§
Row = import from TableDefinitionMethods§
public function __construct(
private string $tableName,
private ?TableDefinition $definition = null,
private string $sql = '',
private RowMatch $match = new \ZtdQuery\Shadow\Row\RowMatch(),
private RowMultiset $rows = new \ZtdQuery\Shadow\Row\RowMultiset(),
)Binds the instance to what it will work from.
Parameters
$tableName | string | Table the result set stands for |
$definition | ?TableDefinition | What that table will and will not hold, where it is known |
$sql | string | Statement to name in anything it refuses |
$match | RowMatch | Finds a row among rows by the key that identifies it |
$rows | RowMultiset | Accounts for rows that repeat |
Test cases 7
SynchronizeMutationTest::testAffectedRowCountCountsMixedInsertUpdateAndDeletecoversSynchronizeMutationTest::testAffectedRowCountMatchesEveryPrimaryKeyAfterAnEarlierMatchcoversSynchronizeMutationTest::testAffectedRowCountUsesMultisetDifferenceWithoutPrimaryKeycoversSynchronizeMutationTest::testAffectedRowCountWithoutPrimaryKeyIgnoresRowOrderingcoversSynchronizeMutationTest::testApplyRejectsDuplicateCandidateKeyscoversSynchronizeMutationTest::testApplyRejectsNullInNotNullColumncoversSynchronizeMutationTest::testTableNameApplyReplacesTheCompleteTableStatecovers
Calls 2
- new RowMatch line 35
- new RowMultiset line 36
public function apply(ShadowStore $store, array $rows): void{@inheritDoc}
Parameters
$store | ShadowStore | |
$rows | array |
Throws
NotNullViolationException When a row leaves null in a column that will not take oneDuplicateKeyException When two rows collide on a candidate keyTest cases 4
SynchronizeMutationTest::testApplyRejectsDuplicateCandidateKeyscovers and callsSynchronizeMutationTest::testApplyRejectsNullInNotNullColumncovers and callsSynchronizeMutationTest::testTableNameApplyReplacesTheCompleteTableStatecovers and callsReferentialIntegrityEnforcerTest::testSynchronizeCascadesDeletedRowscalls
Calls 3
- new NotNullViolationException line 53
- new DuplicateKeyException line 59
- method-call ShadowStore::set() line 70
public function tableName(): stringTable name.
Returns
stringTest cases 1
Count inserted, updated, and deleted rows once each.
Returns
intTest cases 4
SynchronizeMutationTest::testAffectedRowCountCountsMixedInsertUpdateAndDeletecovers and callsSynchronizeMutationTest::testAffectedRowCountMatchesEveryPrimaryKeyAfterAnEarlierMatchcovers and callsSynchronizeMutationTest::testAffectedRowCountUsesMultisetDifferenceWithoutPrimaryKeycovers and callsSynchronizeMutationTest::testAffectedRowCountWithoutPrimaryKeyIgnoresRowOrderingcovers and calls
Calls 4
- function-call
maxline 93 - function-call
countline 94 - method-call RowMultiset::difference() line 94
- method-call RowMatch::positionOfSameKey() line 102
Private surface 5§
Implementation details, listed for orientation only.
private string $tableNameprivate ?TableDefinition $definition = nullprivate string $sql = ''private RowMatch $match = new \ZtdQuery\Shadow\Row\RowMatch()private RowMultiset $rows = new \ZtdQuery\Shadow\Row\RowMultiset()Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
SynchronizeMutationTest::testAffectedRowCountCountsMixedInsertUpdateAndDeletecovers and callsSynchronizeMutationTest::testAffectedRowCountMatchesEveryPrimaryKeyAfterAnEarlierMatchcovers and callsSynchronizeMutationTest::testAffectedRowCountUsesMultisetDifferenceWithoutPrimaryKeycovers and callsSynchronizeMutationTest::testAffectedRowCountWithoutPrimaryKeyIgnoresRowOrderingcovers and callsSynchronizeMutationTest::testApplyRejectsDuplicateCandidateKeyscovers and callsSynchronizeMutationTest::testApplyRejectsNullInNotNullColumncovers and callsSynchronizeMutationTest::testTableNameApplyReplacesTheCompleteTableStatecovers and calls
Other tests reaching this symbol 3
Relations§
Constant reads 1
- class-const packages/ztd-query-core/src/Compatibility/ClassAliases.php packages/ztd-query-core/src/Compatibility/ClassAliases.php:31