Skip to content

Commit

Permalink
Do not calculate checksum when loading changelogs (#3790)
Browse files Browse the repository at this point in the history
* Do not use checksum when creating the key for a changelog.
* Already saw logic should be done by the visitor (that is not able to do it as it is being skipped here)
* Makes sure that all changeset are loaded (and the visitor shall handle them later)
  • Loading branch information
filipelautert committed Feb 17, 2023
1 parent 6c1b801 commit 99d2188
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void run() throws Exception {
BufferedLogService bufferLog = new BufferedLogService();
CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
Scope.child(Scope.Attr.changeSet.name(), changeSet, () -> {
if (finalShouldVisit && !alreadySaw(changeSet)) {
if (finalShouldVisit) {
//
// Go validate any changesets with an Executor if
// we are using a ValidatingVisitor
Expand Down Expand Up @@ -193,19 +193,12 @@ protected String createKey(ChangeSet changeSet) {
ContextExpression contexts = changeSet.getContextFilter();
changeSet.getRunOrder();

return changeSet.toString(true)
return changeSet.toString(false)
+ ":" + (labels == null ? null : labels.toString())
+ ":" + (contexts == null ? null : contexts.toString())
+ ":" + StringUtil.join(changeSet.getDbmsSet(), ",");
}

protected boolean alreadySaw(ChangeSet changeSet) {
if (changeSet.key == null) {
changeSet.key = createKey(changeSet);
}
return seenChangeSets.contains(changeSet.key);
}

public List<ChangeSetFilter> getChangeSetFilters() {
return Collections.unmodifiableList(changeSetFilters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class XMLChangeLogSAXParserTest extends Specification {
</databaseChangeLog>
"""

def testIgnoreDuplicateChangeSets() throws ChangeLogParseException, Exception {
def testAllProvidedChangesetsAreLoaded() throws ChangeLogParseException, Exception {
when:
def xmlParser = new XMLChangeLogSAXParser()
def changeLog = xmlParser.parse("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/master.changelog.xml",
Expand All @@ -72,7 +72,7 @@ class XMLChangeLogSAXParserTest extends Specification {


then:
changeSets.size() == 8
changeSets.size() == 14
changeSets.get(0).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser"
changeSets.get(1).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser"
changeSets.get(1).getContextFilter().getContexts().size() == 1
Expand All @@ -83,8 +83,9 @@ class XMLChangeLogSAXParserTest extends Specification {
changeSets.get(4).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser"
changeSets.get(4).getDbmsSet().size() == 1
changeSets.get(5).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog1.xml::1::testuser"
changeSets.get(6).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog3.xml::1::testuser"
changeSets.get(7).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog2.xml::1::testuser"
changeSets.get(6).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser"
changeSets.get(7).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser"
changeSets.get(13).toString() == "liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog3.xml::1::testuser"
}

def "uses liquibase.secureParsing by default"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
<column name="locked" type="boolean"/>
</createTable>
</changeSet>
<changeSet id="sampleCSVData" author="nvoxland">
<changeSet id="sampleCSVData1" author="nvoxland">
<loadData tableName="csvdata" file="changelogs/sample.data1.csv"/>
</changeSet>
<changeSet id="sampleTSVData" author="nvoxland">
Expand All @@ -507,7 +507,7 @@
</loadData>
</changeSet>

<changeSet id="sampleCSVData" author="nvoxland">
<changeSet id="sampleCSVData4" author="nvoxland">
<loadData tableName="csvdata" file="changelogs/sample.data1.csv.gz"/>
</changeSet>

Expand Down

0 comments on commit 99d2188

Please sign in to comment.