Skip to content

Commit

Permalink
Merge pull request #4433 from liquibase/fix-error-if-missing
Browse files Browse the repository at this point in the history
Rollback errorIfMissingOrEmpty parameter for includeAll tag
  • Loading branch information
filipelautert committed Jun 23, 2023
2 parents b05aee7 + 38f1b43 commit e8eb891
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ protected void handleChildNode(ParsedNode node, ResourceAccessor resourceAccesso
ignore = false;
}
includeAll(path, node.getChildValue(null, "relativeToChangelogFile", false), resourceFilter,
node.getChildValue(null, "errorIfMissing", true),
node.getChildValue(null, "errorIfMissingOrEmpty", true),
resourceComparator,
resourceAccessor,
includeContextFilter,
Expand Down Expand Up @@ -630,7 +630,7 @@ public boolean isDbmsMatch(Set<String> dbmsSet) {
public void includeAll(String pathName,
boolean isRelativeToChangelogFile,
IncludeAllFilter resourceFilter,
boolean errorIfMissing,
boolean errorIfMissingOrEmpty,
Comparator<String> resourceComparator,
ResourceAccessor resourceAccessor,
ContextExpression includeContextFilter,
Expand All @@ -644,7 +644,7 @@ public void includeAll(String pathName,
includeAll(pathName,
isRelativeToChangelogFile,
resourceFilter,
errorIfMissing,
errorIfMissingOrEmpty,
resourceComparator,
resourceAccessor,
includeContextFilter,
Expand All @@ -656,7 +656,7 @@ public void includeAll(String pathName,
public void includeAll(String pathName,
boolean isRelativeToChangelogFile,
IncludeAllFilter resourceFilter,
boolean errorIfMissing,
boolean errorIfMissingOrEmpty,
Comparator<String> resourceComparator,
ResourceAccessor resourceAccessor,
ContextExpression includeContextFilter,
Expand All @@ -665,14 +665,14 @@ public void includeAll(String pathName,
int minDepth,
int maxDepth)
throws SetupException {
includeAll(pathName, isRelativeToChangelogFile, resourceFilter, errorIfMissing, resourceComparator,
includeAll(pathName, isRelativeToChangelogFile, resourceFilter, errorIfMissingOrEmpty, resourceComparator,
resourceAccessor, includeContextFilter, labels, ignore, minDepth, maxDepth, new ModifyChangeSets(null, null));
}

public void includeAll(String pathName,
boolean isRelativeToChangelogFile,
IncludeAllFilter resourceFilter,
boolean errorIfMissing,
boolean errorIfMissingOrEmpty,
Comparator<String> resourceComparator,
ResourceAccessor resourceAccessor,
ContextExpression includeContextFilter,
Expand Down Expand Up @@ -722,7 +722,7 @@ public void includeAll(String pathName,

unsortedResources = resourceAccessor.search(path, searchOptions);
} catch (IOException e) {
if (errorIfMissing) {
if (errorIfMissingOrEmpty) {
throw new IOException(String.format("Could not find/read changelogs from %s directory", pathName));
}
}
Expand All @@ -735,15 +735,15 @@ public void includeAll(String pathName,
}
}

if (resources.isEmpty() && errorIfMissing) {
if (resources.isEmpty() && errorIfMissingOrEmpty) {
throw new SetupException(
"Could not find directory or directory was empty for includeAll '" + pathName + "'");
}

Scope.child(Collections.singletonMap(SEEN_CHANGELOGS_PATHS_SCOPE_KEY, seenChangelogPaths), () -> {
for (Resource resource : resources) {
Scope.getCurrentScope().getLog(getClass()).info("Reading resource: " + resource);
include(resource.getPath(), false, errorIfMissing, resourceAccessor, includeContextFilter,
include(resource.getPath(), false, errorIfMissingOrEmpty, resourceAccessor, includeContextFilter,
labels, ignore, OnUnknownFileFormat.WARN, modifyChangeSets);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
<xsd:attribute name="path" type="xsd:string" use="required"/>
<xsd:attribute name="errorIfMissingOrEmpty" type="booleanExp" default="true"/>
<xsd:attribute name="relativeToChangelogFile" type="booleanExp"/>
<xsd:attribute name="errorIfMissing" type="booleanExp" default="true"/>
<xsd:attribute name="resourceComparator" type="xsd:string"/>
<xsd:attribute name="filter" type="xsd:string"/>
<xsd:attribute name="context" type="xsd:string"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
<xsd:attribute name="path" type="xsd:string" use="required"/>
<xsd:attribute name="errorIfMissingOrEmpty" type="booleanExp" default="true"/>
<xsd:attribute name="relativeToChangelogFile" type="booleanExp"/>
<xsd:attribute name="errorIfMissing" type="booleanExp" default="true"/>
<xsd:attribute name="resourceComparator" type="xsd:string"/>
<xsd:attribute name="filter" type="xsd:string"/>
<xsd:attribute name="context" type="xsd:string"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbch
def rootChangeLog = new DatabaseChangeLog(rootChangeLogPath)
rootChangeLog.load(new ParsedNode(null, "databaseChangeLog")
.addChildren([includeAll: [path: includedAllChangeLogPath, minDepth:minDepth, maxDepth:maxDepth, errorIfMissing:false]]), resourceAccessor)
.addChildren([includeAll: [path: includedAllChangeLogPath, minDepth:minDepth, maxDepth:maxDepth, errorIfMissingOrEmpty:false]]), resourceAccessor)
then:
rootChangeLog.getChangeSets().size() == expectedIncludeAllChangesetsToDeploy
Expand Down

0 comments on commit e8eb891

Please sign in to comment.