Skip to content

Commit

Permalink
Applied code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Oct 14, 2021
1 parent 26ca7b0 commit bfbb062
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions eZ/Publish/SPI/Tests/Persistence/FixtureImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ private function resetSequences(array $affectedTables): void
*/
private function getSequenceResetStatements(array $affectedTables): iterable
{
$diff = array_diff($affectedTables, array_keys(self::$resetSequenceStatements));
if (empty($diff)) {
$unvisitedTables = array_diff($affectedTables, array_keys(self::$resetSequenceStatements));
if (empty($unvisitedTables)) {
// Return sequence change commands for affected tables
return array_intersect_key(self::$resetSequenceStatements, array_fill_keys($affectedTables, true));
}
Expand All @@ -139,7 +139,8 @@ private function getSequenceResetStatements(array $affectedTables): iterable
$queryTemplate = 'SELECT setval(\'%s\', %s) FROM %s';

$schemaManager = $this->connection->getSchemaManager();
foreach ($diff as $tableName) {
$databasePlatform = $this->connection->getDatabasePlatform();
foreach ($unvisitedTables as $tableName) {
$columns = $schemaManager->listTableColumns($tableName);
foreach ($columns as $column) {
if (!$column->getAutoincrement()) {
Expand All @@ -152,9 +153,7 @@ private function getSequenceResetStatements(array $affectedTables): iterable
self::$resetSequenceStatements[$tableName] = sprintf(
$queryTemplate,
$sequenceName,
$this->connection->getDatabasePlatform()->getMaxExpression(
$this->connection->quoteIdentifier($columnName)
),
$databasePlatform->getMaxExpression($this->connection->quoteIdentifier($columnName)),
$this->connection->quoteIdentifier($tableName)
);
}
Expand Down

0 comments on commit bfbb062

Please sign in to comment.