New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Underscore in schemaName causes error relation "databasechangelog" already exists #1604
Comments
Hi @urvanov-ru Thanks for this excellent repro and an repo that shows the issue. We will add this to our list of issues to process. |
Maybe we can use |
Hi @urvanov-ru and @molivasdat Any news on this issue? +1 Thanks & |
+1 |
I am sorry, but I had no time to do anything in this issue. I tried to fix it, but it is not one line fixing bug |
@urvanov-ru |
Hi @urvanov-ru or @molivasdat Thanks & rest regards |
Hi @tomtrapp Yes we are gearing up to start moving quick a bit quicker with our updates. Not quite there yet. The workaround for now would be use another name that does not include _ in the schema name. |
The fix adds escaping for both Special Thanks! Thank you, @urvanov-ru, for the project that reproduces the bug. As a QA, I cannot overstate how valuable this is to me. As demonstrated in the github repro project, the steps to see the bug are:
Postgres Validation
SQL Server Validation
Test Environment |
Environment
Liquibase Version : 4.11
Liquibase Integration & Version: ---
Liquibase Extension(s) & Version: ---
Database Vendor & Version: PostgreSQL 11
Operating System Type & Version: Ubuntu 20.04.1 LTS
Description
liquibase.snapshot.JdbcDatabaseSnapshot searchs tables using:
databaseMetaData is an instance of java.sql.DatabaseMetadata. Liquibase passes schemaName to #getTables to find databasechangelog table. It is "test_schema" in our example. DatabaseMetadata#getTables accepts schemaPattern for SQL LIKE, so it uses his argument in something like:
our underscore character is a replacement for any other character, so it receives two rows for our table: one for test-schema and the second for test_schema. Then inside Liquibase it goes through compare chain and skips that received table, because it is not in our test_schema, it is in test-schema. Liquibase thinks that databasechangelog does not exist, and it tries to create it. But our test_schema already has databasechangelog table from the first run.
Steps To Reproduce
Example project: https://github.com/urvanov-ru/liquibase-schemaname/tree/main/liquibase-schemaname
We have two schemas: test-schema and test_schema in PostgreSQL database.
The first run of test project always successful. The second run fails.
We see error:
Actual Behavior
The second run of https://github.com/urvanov-ru/liquibase-schemaname/tree/main/liquibase-schemaname fails.
Expected/Desired Behavior
The second run of https://github.com/urvanov-ru/liquibase-schemaname/tree/main/liquibase-schemaname should be successful. test-schema should use only test-schema objects, test_schema should use only test_schema objects.
I have been using Liquibase for many years. Thank you for really good project. I am really looking forward for any workaround or bugfix for the problem.
┆Issue is synchronized with this Jira Bug by Unito
┆fixVersions: Community 4.x
The text was updated successfully, but these errors were encountered: