Skip to content

Commit

Permalink
Merge pull request #134 from liquibase/fix-default-driver-handling
Browse files Browse the repository at this point in the history
Don't force cassandra driver on all databases
  • Loading branch information
molivasdat authored Apr 12, 2022
2 parents bad0a28 + 927e243 commit d2f13f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws D

@Override
public String getDefaultDriver(String url) {
return "com.simba.cassandra.jdbc42.Driver";
if (String.valueOf(url).startsWith("jdbc:cassandra:")) {
return "com.simba.cassandra.jdbc42.Driver";
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import liquibase.database.Database;
import liquibase.database.ObjectQuotingStrategy;
import liquibase.datatype.DataTypeFactory;
import liquibase.exception.DatabaseException;
import liquibase.ext.cassandra.database.CassandraDatabase;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
Expand Down Expand Up @@ -79,13 +80,7 @@ public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlG



} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return super.generateSql(statement, database, sqlGeneratorChain);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException | DatabaseException e) {
return super.generateSql(statement, database, sqlGeneratorChain);
} finally {
database.setObjectQuotingStrategy(currentStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ class CassandraDatabaseTest extends Specification {
new CassandraDatabase().getShortName() == "cassandra"
}

def getDefaultDriver() {
expect:
new CassandraDatabase().getDefaultDriver(null) == null
new CassandraDatabase().getDefaultDriver("jdbc:mysql://localhost") == null
new CassandraDatabase().getDefaultDriver("jdbc:cassandra://localhost") != null
}

}

0 comments on commit d2f13f1

Please sign in to comment.