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
1054 add not null constraint causes data too long exception #2071
1054 add not null constraint causes data too long exception #2071
Conversation
… of https://github.com/nhumblot/liquibase into nhumblot-1054-addNotNullConstraint-causes-DataTooLong-exception
I pushed the current version of master to your fork to fix the build issue. |
Hi @nhumblot Thanks for creating the fix. 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. |
…tNullConstraint-causes-DataTooLong-exception
…DataTooLong-exception
I pushed a change to your fork that replaces the custom boolean parsing with existing functions that do something similar. That should make it a bit more generally applicable. I was hoping to not keep the fix isolated to booleans/bits, but the current datatype APIs don't have the functionality I'd need yet. At some point we can improve it, but for not booleans/bits are likely the biggest source of this "data type too small" error |
…also have booleans
…also have booleans
…DataTooLong-exception
Environment
Liquibase Version:
4.5.0
Liquibase Integration & Version: Spring Boot / Maven in my case but not specific to this integration
Liquibase Extension(s) & Version: N/A
Database Vendor & Version: MySQL
Operating System Type & Version: Not OS specific but I'm running Fedora 34
Pull Request Type
Description
Fix #1054
A clear and concise description of the issue being addressed. Additional guidance here.
Steps To Reproduce
See:
Actual Behavior
Liquibase generates invalid SQL when setting a default value to a boolean column.
Taken from #1054 (comment)
Generates the following error:
Expected/Desired Behavior
Liquibase generates a valid SQL update statement in the form of:
Fast Track PR Acceptance Checklist:
<
!--- If you're unsure about any of these, just ask us in a comment. We're here to help|width=200,height=183!
-->
Need Help?
Come chat with us on our discord channel
Dev Handoff Notes (Internal Use)
Links
Testing
<addNotNullConstraint>
when dataType is a boolean like field for that database. But the logic is applied for all database typesDev Verification
I used a changelog like this:
With the fix, the update correctly runs.
Test Requirements (Liquibase Internal QA)
The manual testing is only required for MySQL database.
Setup
Execute update command against MySQL database (changelog file is attached):
liquibase update --changelog-file lb2187-changelog.xml --labels create,fill
Verify that table
test_table
was successfully created and has 2 rows with data as shown below!Screenshot from 2021-12-15 18-43-12.png|width=25%!
Manual Tests
Verify that
update-sql
generates correct sql code forbit
type.liquibase update-sql --changelog-file lb2187-changelog.xml --labels bit
Verify that
update
is successful forbit
typeliquibase update --changelog-file lb2187-changelog.xml --labels bit
col_name_bit
value for row withid=2
is now 1 instead of [NULL]Verify that
update-sql
generates correct sql code forboolean
type.liquibase update-sql --changelog-file lb2187-changelog.xml --labels bool
Verify that
update
is successful forboolean
typeliquibase update --changelog-file lb2187-changelog.xml --labels bool
col_name_boolean
value for row withid=2
is now 1 instead of [NULL]Automated Tests
┆Issue is synchronized with this Jira Bug by Unito