Skip to content

Commit

Permalink
Do not throw exception when runWith is empty string (DAT-14316) (liqu…
Browse files Browse the repository at this point in the history
…ibase#4495)

* [DAT-14316] Map empty string to null in runWith getter to avoid improper setting with empty string.

* [DAT-14316] Adds test with empty runWith.
  • Loading branch information
abrackx authored Jul 25, 2023
1 parent 034c6c5 commit a2667dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet id="1" author="your.name" labels="example-label" context="example-context" runWith="">
<comment>example-comment</comment>
<createTable tableName="person">
<column name="id" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="name" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="address1" type="varchar(50)"/>
<column name="address2" type="varchar(50)"/>
<column name="city" type="varchar(30)"/>
</createTable>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,18 @@ Optional Args:
'EVENT: ran fired',
]
}

run "Should fall back to jdbc executor when runWith is an empty string", {
arguments = [
url : { it.url },
username : { it.username },
password : { it.password },
changelogFile : 'changelogs/h2/complete/empty.runWith.changelog.xml',
]

expectedResults = [
statusCode: 0,
defaultChangeExecListener: 'not_null'
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ public void setStoredFilePath(String storedFilePath) {
this.storedFilePath = storedFilePath;
}

/**
* @return the runWith value. If the runWith value is empty or not set this method will return null.
*/
public String getRunWith() {
return runWith;
return runWith == null || runWith.isEmpty() ? null : runWith;
}

public void setRunWith(String runWith) {
Expand Down

0 comments on commit a2667dc

Please sign in to comment.