Skip to content
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

Make EnterpriseDBDatabase detection less broad #2364

Merged
merged 4 commits into from Jan 20, 2022
Merged

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Jan 13, 2022

Description

The current implementation of EnterpriseDBDatabase picks up database with just "edb" in the url anywhere vs. an actual edb url.

Fixes #2363

Work Around

You can manually override the (wrongly) detected dialect with databaseClass: liquibase.database.core.MySQLDatabase or databaseClass: liquibase.database.core.DB2Database etc. in your liquibase.properties file.


Dev Handoff Notes (Internal Use)

Links

Testing

Dev Verification

Added automated test to catch the problem

Test Requirements (Liquibase Internal QA)

Manual Tests

Setup: Case 1

  • Create a MySQL database named testedb1
  • Update liquibase.properties file to connect to that database:
    url:jdbc:mysql://localhost:3309/testedb1?useSSL=false&allowPublicKeyRetrieval=true
  • Comment out or delete the driver name in liquibase.properties
  • Comment out or delete the MySQL driver specified in the liquibase.properties classpath.
  • Copy the MySQL driver into the liquibase/lib directory

⚠️ I found that if the driver was specified in the liquibase.properties file, you do not encounter this bug, even when a database URL contains the literal string edb. That is why the setup removes any reference to the driver class or driver jar. Liquibase does not ship with a MySQL jar in lib; we must add that manually to run this test. ⚠️

Error Message output By Bug
[2022-01-19 12:26:29] INFO [liquibase.database] Cannot check pg_settings
java.sql.SQLSyntaxErrorException: Table 'testedb1.pg_settings' doesn't exist

Verify non-Postgres/EDB JDBC URLs with “edb” do not try and use PG/EDB driver.

  • liquibase log-level INFO update-sql --changelog-file <any changelog>
  • update-sql is successful
  • there is no error about “pg_settings” in the output.

Setup Case 2

url:jdbc:edb://localhost:5444/test

  • Do not include driver name or driver jar in liquibase.properties file.
  • Copy the edb jar into the liquibase/lib directory.
  • Rename or delete the postgresql driver jar in liquibase/lib.

Verify the EDB driver is used for a connection that has “edb” AND “:5444”

  • liquibase log-level INFO update-sql --changelog-file <anychangelog>
  • update-sql is successful
  • you do not get an error that the EDB driver cannot be located.

Setup: Case 3

  • Start a second posgres database on the default port (5432)
  • Create a database named ‘test1’
  • Update liquibase.properties to connect to the database:

url: jdbc:postgresql://localhost:5432/test

  • Do not include driver name or driver jar in liquibase.properties file.
  • Ensure the postgres driver is in liquibase/lib

Verify the Postgres driver is used for a connection that has “postgres” and “:5432”

  • liquibase log-level INFO update-sql --changelog-file <anychangelog>
  • update-sql is successful
  • you do not get an error that the EDB driver cannot be located.
  • the postgres driver is used.

Automated Tests

  • None required for this ticket; there are nice unit tests for this change.

┆Issue is synchronized with this Jira Bug by Unito

@nvoxland nvoxland added this to To Do in Conditioning++ via automation Jan 13, 2022
@nvoxland nvoxland moved this from To Do to Code Review in Conditioning++ Jan 13, 2022
@suryaaki2 suryaaki2 moved this from Code Review to Ready for Handoff (In JIRA) in Conditioning++ Jan 18, 2022
@nvoxland
Copy link
Contributor Author

I updated the code to check the connection to know if it's an edb database vs. purely relying on the url.

I left the jdbc:edb and jdbc:postgres checks in there around it, though, for performance reasons.

@liquibase liquibase deleted a comment from sync-by-unito bot Jan 19, 2022
@suryaaki2 suryaaki2 merged commit 157707b into master Jan 20, 2022
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Jan 20, 2022
@suryaaki2 suryaaki2 deleted the edb-check-too-broad branch January 20, 2022 19:50
@nvoxland nvoxland removed this from Done in Conditioning++ Jan 21, 2022
@nvoxland nvoxland added this to the v4.7.1 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants