Skip to content
Browse files

Index comparison not working with case insensitive mysql

  • Loading branch information...
1 parent a2dc52c commit f0d391bb04addc76716a941bd616f51ff2993137 @nvoxland nvoxland committed Mar 20, 2013
View
2 liquibase-core/src/main/java/liquibase/change/core/AddNotNullConstraintChange.java
@@ -66,7 +66,7 @@ public void setColumnName(String columnName) {
this.columnName = columnName;
}
- @DatabaseChangeProperty(description = "Value to set all currently null values to. If not set, change will fail if null values exist", requiredForDatabase = {"informix","mssql"})
+ @DatabaseChangeProperty(description = "Value to set all currently null values to. If not set, change will fail if null values exist")
public String getDefaultNullValue() {
return defaultNullValue;
}
View
9 liquibase-core/src/main/java/liquibase/database/core/MySQLDatabase.java
@@ -40,7 +40,14 @@ public String correctObjectName(String name, Class<? extends DatabaseObject> obj
if (objectType.equals(PrimaryKey.class) && name.equals("PRIMARY")) {
return null;
} else {
- return super.correctObjectName(name, objectType);
+ name = super.correctObjectName(name, objectType);
+ if (name == null) {
+ return null;
+ }
+ if (!this.isCaseSensitive()) {
+ return name.toLowerCase();
+ }
+ return name;
}
}
View
6 ...ibase-core/src/main/java/liquibase/diff/compare/core/DefaultDatabaseObjectComparator.java
@@ -39,7 +39,11 @@ protected boolean nameMatches(DatabaseObject databaseObject1, DatabaseObject dat
if (object1Name == null || object2Name == null) {
return false;
}
- return object1Name.equals(object2Name);
+ if (accordingTo.isCaseSensitive()) {
+ return object1Name.equals(object2Name);
+ } else {
+ return object1Name.equalsIgnoreCase(object2Name);
+ }
}
}
View
12 liquibase-core/src/main/java/liquibase/snapshot/jvm/IndexSnapshotGenerator.java
@@ -238,12 +238,18 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot
}
for (JdbcDatabaseSnapshot.CachedRow row : rs) {
- String indexName = cleanNameFromDatabase(row.getString("INDEX_NAME"), database);
+ String indexName = database.correctObjectName(cleanNameFromDatabase(row.getString("INDEX_NAME"), database), Index.class);
@damienbiggs
damienbiggs added a note Mar 28, 2013

This could potentially create issues for other databases.
It was my understanding that the DatabaseMetaData info returns the index names in the correct case.

@nvoxland
Liquibase member
nvoxland added a note Apr 4, 2013

The trouble I was running into is that the form the database returns may not be the form the user is thinking in on case insensitive databases. I have a test with a change followed by an precondition that was failing because the the snapshot was finding an index called "TEST".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
if (indexName == null) {
continue;
}
- if (exampleName != null && !exampleName.equals(indexName)) {
- continue;
+ if (database.isCaseSensitive()) {
+ if (exampleName != null && !exampleName.equals(indexName)) {
+ continue;
+ }
+ } else {
+ if (exampleName != null && !exampleName.equalsIgnoreCase(indexName)) {
+ continue;
+ }
}
/*
* TODO Informix generates indexnames with a leading blank if no name given.

0 comments on commit f0d391b

Please sign in to comment.
Something went wrong with that request. Please try again.