Skip to content
Snippets Groups Projects
Commit 4b2d588a authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#663 - fixed sequences reset: avoid number formatting

parent 8247d517
No related branches found
No related tags found
No related merge requests found
......@@ -53,8 +53,8 @@ public class GenericStepListener<T extends ProvidesID> implements StepExecutionL
{
final int highestUsedID = getHighestUsedID();
final int newSequence = highestUsedID + 1;
LOGGER.debug("Adjusting sequence to {} ({})", newSequence, highestUsedID);
jdbcTemplate.update(MessageFormat.format("ALTER SEQUENCE {0}_id_seq RESTART WITH {1}", tableName, newSequence));
LOGGER.debug("Adjusting sequence to {} (highest used id: {})", newSequence, highestUsedID);
jdbcTemplate.update(MessageFormat.format("ALTER SEQUENCE {0}_id_seq RESTART WITH {1}", tableName, String.valueOf(newSequence)));
}
return null;
......
......@@ -63,5 +63,8 @@ class UpdateSequencesTest extends MigratorTestBase
final List<DestinationCategory> categoriesOrderedById = categoryRepository.findAllByOrderByIDDesc();
final DestinationCategory savedCategory = categoryRepository.save(new DestinationCategory(null, "New One", "#ffffff", 0, null));
assertThat(savedCategory.getID()).isEqualTo(categoriesOrderedById.get(0).getID() + 1);
final DestinationCategory savedCategory2 = categoryRepository.save(new DestinationCategory(null, "New Two", "#ffffff", 0, null));
assertThat(savedCategory2.getID()).isEqualTo(categoriesOrderedById.get(0).getID() + 2);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment