createIndex does not give desired result when Oracle schema has a hyphen

We fixed this problem by calling escapeDatabaseObject on the schemaName in the escapeIndexName method.

New escapeIndexName method:

  1.     public String escapeIndexName(String schemaName, String indexName) {
  2.         String escapedIndexName = indexName;
  3.         if (schemaName != null)
  4.         {
  5.             escapedIndexName = escapeDatabaseObject(schemaName) + “.” + escapedIndexName;
  6.         }
  7.         return escapedIndexName;
  8.     }

I believe the schema should be surrounded by quotes in liquibase.database.core.OracleDatabase.escapeIndexName, otherwise the query won’t run.

Example output that I get when SpringLiquibase.afterPropertiesSet is called:


SEVERE 04/07/12 5:21 PM:liquibase: Change Set data/liquibase-db-schema-1.0.xml::createPathPageIndex::author failed.  Error: Error executing SQL CREATE UNIQUE INDEX TEST-SCHEMA.path ON “TEST-SCHEMA”.Page(path): ORA-00969: missing ON keyword

liquibase.exception.DatabaseException: Error executing SQL CREATE UNIQUE INDEX TEST-SCHEMA.path ON “TEST-SCHEMA”.Page(path): ORA-00969: missing ON keyword

    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
    at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1075)
    at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1059)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
    at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
    at liquibase.Liquibase.update(Liquibase.java:113)
    at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:244)
…