-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Improve int/tinyint/smallint/bigint handling in H2 #3274
Conversation
882a7ff
to
2c4019e
Compare
0fcf318
to
e96e49c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to be checking the size here for int and converting to the correct actual types, since new h2 does not support precision like that.
But, the issue still exists where someone specifying smallint(3)
or bigint(15)
or whatever will still fail. So I think we need fixes to TinyIntType, SmallIntType, etc. that simply ignore the parameters passed since h2 doesn't support that. I don't think we need to do logic like "smallint(10) means bigint".
Also, could you add a changeset to the h2 integration test changelog with the different int, smallint, etc. types for columns to ensure the final SQL is valid?
@nvoxland If I didn't get it wrong, what you are asking for here is being addressed as part of this PR. Can you please have a look and confirm? Thanks, |
@MalloD12 yes, that other PR picks up the other problems, I hadn't seen that one yet. Since it's touching similar code we could have done it as a single PR addressing both issues, but fine to keep them separate since you've made both already. Both could use integration test items for them still, though. |
if you are ok with that, I can still unify these two PRs in just a single one and then close one of them? I think some of them already have integration test created, but yeah some others don't. |
e96e49c
to
04bc61c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review and test results:
Things to be aware of:
- H2 doesn't support arguments on any of the int datatypes, so this correctly removes them if they are set
- Includes tests to ensure they are as expected
- Only impacts h2
Things to worry about:
- Nothing
Could you please include the fix for BOOLEAN Types as well? Currently with H2 2.1.214, Liquibase is not able to translate 1 to TRUE (or) 0 to FALSE. With previous version of H2 1.4.200, Liquibase was able to translate it. Steps to reproduce:
Reason: liquibase.exception.DatabaseException: Values of types "BOOLEAN" and "INTEGER" are not comparable; SQL statement: |
@VeluchamySC that won't be something we can fix. The It looks like a change in what h2 will do for data type conversions between 1.x and 2.x. If you have just switched to h2 2.x you can update the statement to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
H2 does not support precision in the SQL syntax, but it is valid to include precision in changeset datatype column definitions. This fix correctly "translates" integer datatypes specified with precision when SQL is generated for an H2 database, generating SQL with TINYINT, SMALLINT, INTEGER or BIGINT. Liquibase determines the correct type of integer following the H2 documentation here:
- Comprehensive set of integration tests added.
- No additional testing required.
APPROVED
Any progress on this issue? When can we expect this MR in a liquibase version? greetings, |
Hi @TomBenjamins We are looking for getting another review on this PR. Once that happens we will be ready to merge this. We are expecting to have this close soon to include it in the next release, which hopefully should be in about two weeks. Thanks, |
Hi, Example changeset: If raw sqls won't be addressed then could you please suggest what to do with those old changelogs (already executed on envs like prod, but still used on test)? |
Bump for the fix... |
Impact
Description
Implement support to consider integer precision by parsing to the specific integer type (tiny, integer or bigint) depending on the specified size.
Fixes #3250
Fixes #3300
Things to be aware of
Things to worry about
Additional Context