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

Include column data type to SetColumnRemarksChange for MySQL support #2129

Closed
wants to merge 1 commit into from

Conversation

potados99
Copy link

@potados99 potados99 commented Sep 29, 2021

Environment

Liquibase Version: 4.5.1-local-SNAPSHOT

Database Vendor & Version: MySQL 8

Operating System Type & Version: macOS 11.6

Pull Request Type

  • Bug fix (non-breaking change which fixes an issue.)
  • Enhancement/New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

MySQL needs column data type along with a column remark change. Even if the columnDataType is not actually changed, the type is required for MySQL to modify a remark on the column. So I included it in SetColumnRemarksChange.

Steps To Reproduce

To reproduce a problem this PR is trying to fix:

  1. Prepare two empty MySQL databases(comparison, reference respectively)
  2. Create a table tester, with columns INT(10) id as pk and VARCHAR(10) name, on both databases.
  3. Add a comment to the name column on the reference database.
  4. Create a diffChangeLog in SQL.

These steps will make a NullPointerException:

Caused by: java.lang.NullPointerException
        at liquibase.sqlgenerator.core.SetColumnRemarksGenerator.generateSql(SetColumnRemarksGenerator.java:50)
        at liquibase.sqlgenerator.core.SetColumnRemarksGenerator.generateSql(SetColumnRemarksGenerator.java:15)
        at liquibase.sqlgenerator.SqlGeneratorChain.generateSql(SqlGeneratorChain.java:30)
        at liquibase.sqlgenerator.SqlGeneratorFactory.generateSql(SqlGeneratorFactory.java:220)
        at liquibase.sqlgenerator.SqlGeneratorFactory.generateSql(SqlGeneratorFactory.java:206)
        at liquibase.serializer.core.formattedsql.FormattedSqlChangeLogSerializer.serialize(FormattedSqlChangeLogSerializer.java:58)
        at liquibase.serializer.core.formattedsql.FormattedSqlChangeLogSerializer.write(FormattedSqlChangeLogSerializer.java:104)
        at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:248)
        at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:137)
        ... 21 more

The line that throws the exception requires a column data type, which does not exist, because the data type is not actually changed.

+ DataTypeFactory.getInstance().fromDescription(statement.getColumnDataType(), database).toDatabaseDataType(database)

@molivasdat
Copy link
Contributor

Hi @potados99 Thanks for creating this fix.
We will add to the list of PRs that we are processing.

A member of the Liquibase team will take a look at your contribution and may suggest:

The PR will be prioritized according to our internal development and testing capacity.

We’ll let you know when it’s ready to move to the next step or if any changes are needed.

@molivasdat molivasdat added this to To Do in Conditioning++ via automation Nov 23, 2021
@molivasdat molivasdat added BKeyPlatform Key Platform DBMySQL ImpactLow IntegrationCLI RiskMedium Changes that require more testing or that affect many different code paths. Severity3 TypeBug labels Nov 23, 2021
@nvoxland
Copy link
Contributor

This is a duplicate of #2188 which is already in flight.

Thanks!

@nvoxland nvoxland closed this Dec 22, 2021
Conditioning++ automation moved this from To Do to Done Dec 22, 2021
@nvoxland nvoxland removed this from Done in Conditioning++ Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BKeyPlatform Key Platform DBMySQL ImpactLow IntegrationCLI RiskMedium Changes that require more testing or that affect many different code paths. Severity3 TypeBug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants