Generate Change Log in case sensitive database fails.

I tried generating a change log using many different versions of Liquibase and keep getting an error with “invalid column name”. I eventually downloaded the source and debugged the code and found the problem occurs when there are two different tables with the same name, but a difference in case. Problem is in class liquibase.database.Database.DatabaseSnapshot, Method getTable :

    public Table getTable(String tableName) {
        for (Table table : getTables()) {
            if (table.getName().equalsIgnoreCase(tableName)) {
                return table;
            }
        }
        return null;
    }

changed “equalsIgnoreCase” to “equals” and appears to work. Unsure if there are problems elsewhere in the code

Yes, I noticed this also and raised an issue: http://liquibase.jira.com/browse/CORE-813

But I am not sure how this could easily be fixed. I think the problem is that SQL identifiers are case sensitive on some database and not case sensitive on others. I guess Liquibase tries to normalize them to uppercase names (and additionally escapes them if they are contained in a database specific list). I have no clue what would happen if all equalsIgnoreCase() would be replaced by equals() and all toUpperCase() would be removed. Likely this would break existing scenarios - especially if different databases are involved.

BTW that is still a question to me: Is Liquibase meant to support a workflow where you generate changesets in a development environment and apply changes to a testing / production environment with another database flavour?

Sven

@sven With respect to your question concerning workflow with different database flavours: I am under the impression that liquibase is meant to support this workflow.

It should work.  I submitted some fixes for the 2.0.1 release that should solve it for you.  I’m hoping to release 2.0.1 next week

Nathan

Thanks for replying. I don’t know if the issue of the OP is solved, but I would like to let you know that CORE-813 is not solved by these fixes.
But I do not want to hijack this thread, therefore I posted some comments there:
http://liquibase.jira.com/browse/CORE-813

Best regards,

Sven

I’ll take a look at your issue.  Thanks for the info.

Nathan