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

addNotNullConstraint causes "Data too long" Exception for BIT(1) fields #1054

Closed
philhinco opened this issue Mar 25, 2020 · 2 comments · Fixed by #2071
Closed

addNotNullConstraint causes "Data too long" Exception for BIT(1) fields #1054

philhinco opened this issue Mar 25, 2020 · 2 comments · Fixed by #2071
Labels
DBMariaDB DBMySQL good first issue This issue is an easy starter project for new contributors. hacktoberfest a month-long celebration of open-source software and Developers contribute by completing PRs ImpactLow Severity3 TypeBug
Milestone

Comments

@philhinco
Copy link

philhinco commented Mar 25, 2020

Description
We forgot to add a not null constraint to a column that was added to a table in a previous changeset, so now we wanted to add that not-null constraint to said new column.
The data type of that column is BIT(1) (so basically a boolean).

Sidenote: We are using MySQL/MariaDB.

I used the following XML-changeset to add the constraint:

<changeSet id="XXX" author="XXX">
    <addNotNullConstraint tableName="XX" columnName="XX" defaultNullValue="1" columnDataType="BIT(1)"/>
</changeSet>

When we run the changeset, the following Exception is thrown:

Error setting up or running Liquibase: Migration failed for change set xxx.xml::xxxx::XXX:
[ERROR]      Reason: liquibase.exception.DatabaseException: (conn=28) Data too long for column 

I saw that a similar issue was already brought up in 2010 (!) on the Liquibase JIRA board here, but was apparently never fixed.

To Reproduce
Use a changeset like this:

<addColumn tableName="xxx">
   <column name="col_name" type="BIT(1)" defaultValue="1"></column>
</addColumn> 

After that, add a second changeset like this:

<changeSet id="XXX" author="XXX">
    <addNotNullConstraint tableName="xxx" columnName="col_name" defaultNullValue="1" columnDataType="BIT(1)"/>
</changeSet>

Then run the liquibase changeset and the mentioned Exception should be thrown.
Please specify the exact commands used, from CLI, from maven, etc.

Describe the actual problematic behavior. Include console outout if relevant, log files if available. Ensure private information is redacted.

Expected behavior
I expect the changeset to run through without issues, adding the not null constraint to the specified table and setting all NULL entries to the specified default in defaultNullValue.
As mentioned in the comment on the linked JIRA post above, adding attributes like defaultNullValueBoolean would also be helpful.

Screenshots
None

Additional context
None

@SteveDonie
Copy link
Contributor

Thanks for the bug report! We are reviewing all the open issues and will try to get this addressed as soon as possible.

@molivasdat molivasdat added ImpactLow RiskMedium Changes that require more testing or that affect many different code paths. Severity3 TypeBug labels May 11, 2020
@molivasdat molivasdat added DBMariaDB DBMySQL and removed RiskMedium Changes that require more testing or that affect many different code paths. labels May 19, 2020
@molivasdat molivasdat added good first issue This issue is an easy starter project for new contributors. hacktoberfest a month-long celebration of open-source software and Developers contribute by completing PRs labels Sep 26, 2020
@RG9
Copy link
Contributor

RG9 commented Mar 23, 2021

Hi,
I have the same problem with addNotNullConstraint on MySQL:

<addNotNullConstraint tableName="FOO" columnName="BAR" columnDataType="BOOLEAN" defaultNullValue="false"/>

generates SQL:

 UPDATE FOO SET BAR = 'false' WHERE BAR IS NULL

But false shouldn't be quoted with '.

nhumblot added a commit to nhumblot/liquibase that referenced this issue Sep 3, 2021
nhumblot added a commit to nhumblot/liquibase that referenced this issue Sep 3, 2021
nhumblot added a commit to nhumblot/liquibase that referenced this issue Sep 3, 2021
nhumblot added a commit to nhumblot/liquibase that referenced this issue Sep 3, 2021
@nvoxland nvoxland added this to To Do in Conditioning++ via automation Dec 10, 2021
@nvoxland nvoxland moved this from To Do to Code Review in Conditioning++ Dec 10, 2021
@suryaaki2 suryaaki2 moved this from Code Review to Ready for Handoff (In JIRA) in Conditioning++ Dec 13, 2021
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Dec 23, 2021
@nvoxland nvoxland removed this from Done in Conditioning++ Jan 6, 2022
@nvoxland nvoxland added this to the v4.7.0 milestone Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DBMariaDB DBMySQL good first issue This issue is an easy starter project for new contributors. hacktoberfest a month-long celebration of open-source software and Developers contribute by completing PRs ImpactLow Severity3 TypeBug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants