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

Fixed issue that unique constraint precondition does not honor schemaName attribute on MySQL #5783

Merged
merged 6 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
Expand Up @@ -97,10 +97,15 @@ public ValidationErrors validate(Database database) {
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet, ChangeExecListener changeExecListener)
throws PreconditionFailedException, PreconditionErrorException {

String schemaName = getSchemaName();
mpvvliet marked this conversation as resolved.
Show resolved Hide resolved
if (schemaName == null) {
schemaName = database.getDefaultSchemaName();
}

UniqueConstraint example = new UniqueConstraint(
StringUtil.trimToNull(getConstraintName()),
StringUtil.trimToNull(getCatalogName()),
StringUtil.trimToNull(getSchemaName()),
StringUtil.trimToNull(schemaName),
StringUtil.trimToNull(getTableName()));

String columnNames = StringUtil.trimToNull(getColumnNames());
Expand Down
Expand Up @@ -172,7 +172,7 @@ protected List<CachedRow> listConstraints(Table table, DatabaseSnapshot snapshot
+ "on const.constraint_schema=col.constraint_schema "
+ "and const.table_name=col.table_name "
+ "and const.constraint_name=col.constraint_name "
+ "where const.constraint_schema='" + database.correctObjectName(schema.getCatalogName(), Catalog.class) + "' ";
+ "where const.constraint_schema='" + database.correctObjectName(schema.getSchema().getName(), Schema.class) + "' ";
if (!bulkQuery) {
sql += "and const.table_name='" + database.correctObjectName(example.getRelation().getName(), Table.class) + "' "
+ "and const.constraint_name='" + database.correctObjectName(name, UniqueConstraint.class) + "'";
Expand Down