Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default implementation of handleInvalidEmptyPreconditionCase added in AbtractFormattedChangeLogParser to avoid breaking extensions #5660

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@

protected abstract void handlePreconditionsCase(ChangeSet changeSet, int count, Matcher preconditionsMatcher) throws ChangeLogParseException;

protected abstract void handleInvalidEmptyPreconditionCase(ChangeLogParameters changeLogParameters, ChangeSet changeSet, Matcher preconditionMatcher) throws ChangeLogParseException;

protected abstract AbstractSQLChange getChange();

protected abstract String getDocumentationLink();
Expand Down Expand Up @@ -610,6 +608,23 @@
return resourceAccessor.getExisting(physicalChangeLogLocation).openInputStream();
}

protected void handleInvalidEmptyPreconditionCase(ChangeLogParameters changeLogParameters, ChangeSet changeSet, Matcher preconditionMatcher) throws ChangeLogParseException {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'changeLogParameters' is never used.

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'changeSet' is never used.
if (preconditionMatcher.groupCount() == 1) {
String name = StringUtil.trimToNull(preconditionMatcher.group(1));
if (name != null) {
if ("sql-check".equals(name)) {
throw new ChangeLogParseException("Precondition sql check failed because of missing required expectedResult and sql parameters.");
} else if ("table-exists".equals(name)) {
throw new ChangeLogParseException("Precondition table exists failed because of missing required table name parameter.");
} else if ("view-exists".equals(name)) {
throw new ChangeLogParseException("Precondition view exists failed because of missing required view name parameter.");
} else {
throw new ChangeLogParseException("The '" + name + "' precondition type is not supported.");
}
}
}
}

private void handleRollbackSequence(String physicalChangeLogLocation, ChangeLogParameters changeLogParameters, DatabaseChangeLog changeLog, StringBuilder currentRollbackSequence, ChangeSet changeSet, Matcher rollbackSplitStatementsPatternMatcher, boolean rollbackSplitStatements, String rollbackEndDelimiter) throws ChangeLogParseException {
String currentRollbackSequenceAsString = currentRollbackSequence.toString();
if (StringUtil.trimToNull(currentRollbackSequenceAsString) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,6 @@ protected void handlePreconditionsCase(ChangeSet changeSet, int count, Matcher p
}
}

@Override
protected void handleInvalidEmptyPreconditionCase(ChangeLogParameters changeLogParameters, ChangeSet changeSet, Matcher preconditionMatcher) throws ChangeLogParseException {
if (preconditionMatcher.groupCount() == 1) {
String name = StringUtil.trimToNull(preconditionMatcher.group(1));
if (name != null) {
if ("sql-check".equals(name)) {
throw new ChangeLogParseException("Precondition sql check failed because of missing required expectedResult and sql parameters.");
} else if ("table-exists".equals(name)) {
throw new ChangeLogParseException("Precondition table exists failed because of missing required table name parameter.");
} else if ("view-exists".equals(name)) {
throw new ChangeLogParseException("Precondition view exists failed because of missing required view name parameter.");
} else {
throw new ChangeLogParseException("The '" + name + "' precondition type is not supported.");
}
}
}
}

@Override
protected void handlePreconditionCase(ChangeLogParameters changeLogParameters, ChangeSet changeSet, Matcher preconditionMatcher) throws ChangeLogParseException {
if (changeSet.getPreconditions() == null) {
Expand Down