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

Fix for working with Firebird 2 and newer versions. Fixes nullables and boolean type. #2277

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

mngsgoncalves
Copy link
Contributor

Fix for working with Firebird 2 and newer versions. Fixes nullables and boolean type.

Current implementation does not handle correctly working on Firebird 2.5 and Firebird 3 databases. It always assumes a Firebird 3 database, which incurs in invalid SQL statements.

The proposed fix eliminates the Firebird3Database class and instead includes a "version2" attribute in the FirebirdDatabase class. This attribute is populated when the connection is set.

I've fixed the tests and impacted classes (BooleanType and SetNullableGenerator) for this implementation.

@kataggart
Copy link
Contributor

Thanks @mngsgoncalves for taking the time to look into this and propose the fix. We are reviewing.

@nvoxland
Copy link
Contributor

nvoxland commented Jan 5, 2022

I like the removal of the Firebird3 class since that is not really our standard way of working. However, if anyone has extensions that depend on Firebird3 that will break them, so we may need to re-introduce it as a deprectated class to be safe.

I'm currently working on a big improvement to the integration test system, and am going to leave this open for a little bit since it will be a good test of it as I add firebird support in. Should be able to get to it soon, though.

…ves/liquibase into mngsgoncalves-fix-firebird-booleans

# Conflicts:
#	liquibase-core/src/main/resources/META-INF/services/liquibase.database.Database
#	liquibase-integration-tests/src/test/java/liquibase/statementexecute/UnlockDatabaseChangeLogExecuteTest.java
@nvoxland nvoxland changed the base branch from master to 1_9 May 27, 2022 21:59
@nvoxland nvoxland changed the base branch from 1_9 to master May 27, 2022 22:00
Copy link
Contributor

@nvoxland nvoxland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the custom isVersion2() logic for the standard getDatabaseMajorVersion check, with an assumption it's 3+ since 2.x versions are no longer supported by firebird.

Otherwise looks good, and the test-harness tests should catch any issues with firebird 3 or 4

@nvoxland nvoxland added the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label May 27, 2022
@github-actions
Copy link

Unit Test Results

  4 512 files  ±0    4 512 suites  ±0   33m 24s ⏱️ +55s
  4 419 tests ±0    4 205 ✔️ +4     214 💤  - 4  0 ±0 
52 308 runs  ±0  47 300 ✔️ +4  5 008 💤  - 4  0 ±0 

Results for commit e2e53c1. ± Comparison against base commit 4ab687b.

@nvoxland
Copy link
Contributor

The failing functional test is unrelated to the changes

@@ -19,11 +20,18 @@ public class BooleanType extends LiquibaseDataType {
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
if ((database instanceof Firebird3Database)) {
if ((database instanceof FirebirdDatabase)) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a non-developer, I find the use of a try/catch instead of if/else interesting. If anyone has time, can you please explain the advantages of this approach? I'm always happy to learn something new. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XDelphiGrl try/catch is how Java does the exception handling, use of try/catch blocks segregates error-handling code and program code making it easier to identify the logical flow of a program. The logic in the program code does not include details of the actions to be performed when an exception occurs. Such details are present in the catch blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvoxland Do we want to log the exception??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the explanation, @suryaaki2!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a log of the exception

Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change replaces the Firebird3Database class with more streamlined logic to determine Firebird version. Depending on the Firebird version, different SQL is generated for both setting the boolean datatype and setting the nullable state of a column.

  • Fix specific to the Firebird database.
  • Existing unit tests updated to reflect removal of the Firebird3Database class.
  • No additional testing required.

APPROVED

Functional Tests
Passing Test Harness Execution
NOTE: Test failures in the functional test suite are due to mismatch in expected console output and actual console output for the checks feature. These are unrelated to the changes in this PR and can be disregarded.

@@ -19,11 +20,18 @@ public class BooleanType extends LiquibaseDataType {
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
if ((database instanceof Firebird3Database)) {
if ((database instanceof FirebirdDatabase)) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XDelphiGrl try/catch is how Java does the exception handling, use of try/catch blocks segregates error-handling code and program code making it easier to identify the logical flow of a program. The logic in the program code does not include details of the actions to be performed when an exception occurs. Such details are present in the catch blocks.

@@ -19,11 +20,18 @@ public class BooleanType extends LiquibaseDataType {
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
if ((database instanceof Firebird3Database)) {
if ((database instanceof FirebirdDatabase)) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nvoxland Do we want to log the exception??

@nvoxland nvoxland merged commit 81b5112 into liquibase:master Jun 3, 2022
Conditioning++ automation moved this from To Do to Done Jun 3, 2022
@kataggart kataggart added this to the NEXT milestone Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocandidate DBFirebird ImpactMedium IntegrationAny SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions Severity4 TypeBug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants