liquibase/liquibase — pull request #157 by mukhanov (2013-08-16 09:24:17+00:00)
Title: Fixed Oracle update error - unquoted reserved word

Hi there,
Even if I've added "PASSWORD" reserved word I still have [that error](https://github.com/liquibase/liquibase/pull/154) -
>*Caused by: liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: ORA-00904: "PASSWORD": invalid identifier
at liquibase.snapshot.jvm.ColumnSnapshotGenerator.snapshotObject(ColumnSnapshotGenerator.java:58)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:42)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:75)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:144)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:157)
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:124)
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:107)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:94)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:128)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:139)
at liquibase.snapshot.SnapshotGeneratorFactory.getDatabaseChangeLogTable(SnapshotGeneratorFactory.java:146)
at liquibase.database.AbstractJdbcDatabase.checkDatabaseChangeLogTable(AbstractJdbcDatabase.java:619)
... 5 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "PASSWORD": invalid identifier
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:452)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:400)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:884)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:471)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:199)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:535)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:197)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:1165)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1444)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1662)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1958)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:1695)
at liquibase.snapshot.jvm.ColumnSnapshotGenerator.readColumn(ColumnSnapshotGenerator.java:137)
at liquibase.snapshot.jvm.ColumnSnapshotGenerator.snapshotObject(ColumnSnapshotGenerator.java:53)
... 22 more*

I'll try to explain the reason why I've override that method.
In parent method *quotingStrategy* is always equals *ObjectQuotingStrategy.LEGACY*
#### Parent method:
```java
public String escapeObjectName(String objectName, Class objectType) {
if (objectName == null || quotingStrategy == ObjectQuotingStrategy.LEGACY) {
return objectName;
} else if (objectName.contains("-") || startsWithNumeric(objectName) || isReservedWord(objectName)) {
return quotingStartCharacter + objectName + quotingEndCharacter;
} else if (quotingStrategy == ObjectQuotingStrategy.QUOTE_ALL_OBJECTS) {
return quotingStartCharacter + objectName + quotingEndCharacter;
}
return objectName;
}
```
Then it just doesn't try to check reserved words.
I've changed this behaviour in Oracle implementation:
#### Oracle method:
```java
public String escapeObjectName(String objectName, Class objectType) {
if (objectName != null) {
if (objectName.contains("-") || startsWithNumeric(objectName) || isReservedWord(objectName)) {
return quotingStartCharacter + objectName + quotingEndCharacter;
} else if (quotingStrategy == ObjectQuotingStrategy.QUOTE_ALL_OBJECTS) {
return quotingStartCharacter + objectName + quotingEndCharacter;
}
}
return objectName;
}
```
and this fixed the problem.