Skip to content

Commit 266ac29

Browse files
fix: rollback issue (#3)
1 parent cda9af9 commit 266ac29

3 files changed

Lines changed: 4 additions & 37 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ allprojects {
2222
val declaredVersion = "1.3.2-SNAPSHOT"
2323
version = VersionManager.resolveVersion(declaredVersion, project.hasProperty("release"))
2424

25-
extra["templateApiVersion"] = "1.3.4"
25+
extra["templateApiVersion"] = "1.3.2"
2626
extra["flamingockVersion"] = "1.2.1"//for tests
2727

2828
repositories {

flamingock-sql-template/src/main/java/io/flamingock/template/sql/SqlTemplate.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
* executed via {@link java.sql.Statement#execute(String)}.
5454
*
5555
* <p>The {@code rollback} payload is optional ({@code rollbackPayloadRequired = false}).
56-
* If absent or blank, {@link #rollback(Connection)} is a no-op.
56+
* If absent, the framework skips the rollback method entirely. If present, the framework's
57+
* {@code TemplateString} validation rejects null or blank values at pipeline load time.
5758
*
5859
* @see SqlTemplateConfig for configuration options
5960
*/
@@ -69,10 +70,7 @@ public void apply(Connection connection) {
6970

7071
@RollbackTemplate
7172
public void rollback(Connection connection) {
72-
if (rollbackPayload != null && rollbackPayload.getValue() != null
73-
&& !rollbackPayload.getValue().trim().isEmpty()) {
74-
execute(connection, rollbackPayload.getValue());
75-
}
73+
execute(connection, rollbackPayload.getValue());
7674
}
7775

7876
private void execute(Connection connection, String sql) {

flamingock-sql-template/src/test/java/io/flamingock/template/sql/SqlTemplateTest.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import static org.mockito.ArgumentMatchers.anyString;
4646
import static org.mockito.Mockito.*;
4747

48-
@Disabled
4948
class SqlTemplateTest {
5049

5150
private static final String TEST_TABLE = "test_users";
@@ -164,36 +163,6 @@ void rollbackExecution() throws Exception {
164163
verify(mockStatement, times(1)).execute(rollbackSql.trim());
165164
}
166165

167-
@Test
168-
@DisplayName("P0-C: WHEN rollbackPayload is null THEN rollback() does not execute any SQL")
169-
void rollbackNullPayloadGuard() throws Exception {
170-
SqlTemplate template = new SqlTemplate();
171-
// rollbackPayload is null by default — no setRollbackPayload() call
172-
173-
Connection mockConnection = Mockito.mock(Connection.class);
174-
Statement mockStatement = Mockito.mock(Statement.class);
175-
when(mockConnection.createStatement()).thenReturn(mockStatement);
176-
177-
template.rollback(mockConnection);
178-
179-
verify(mockStatement, never()).execute(anyString());
180-
}
181-
182-
@Test
183-
@DisplayName("P0-C: WHEN rollbackPayload value is empty string THEN rollback() does not execute any SQL")
184-
void rollbackEmptyPayloadGuard() throws Exception {
185-
SqlTemplate template = new SqlTemplate();
186-
template.setRollbackPayload(new TemplateString(""));
187-
188-
Connection mockConnection = Mockito.mock(Connection.class);
189-
Statement mockStatement = Mockito.mock(Statement.class);
190-
when(mockConnection.createStatement()).thenReturn(mockStatement);
191-
192-
template.rollback(mockConnection);
193-
194-
verify(mockStatement, never()).execute(anyString());
195-
}
196-
197166
@Test
198167
@DisplayName("WHEN rollback SQL is executed against a real database THEN the database reflects the rollback")
199168
void rollbackExecutesAgainstRealDatabase() throws Exception {

0 commit comments

Comments
 (0)