-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Changeset generates wrong CREATE TABLE query for auto increment primary key column #2362
Comments
have a similar problem, it looks as if the newer keywords in liquibase 2.x are not applied:
I am not entirely sure why this is happening, since the PR https://github.com/liquibase/liquibase/pull/2285/files#diff-585aea777bfaf5867d624fd65d291f5f3aa3ae3662293eea3a5cb4a94a4b2dabR86 looked as if it would add those new keywords. From the release notes it looked as if 4.7.0 would include the support for newer h2 version (and therefore also 4281f9c) |
@nvoxland can you please take a look? |
ok, actually I am seeing a different problem, when using variables then the reserved keyword quoting does not seem to work
|
I can also reproduce the problem with autoincrement:
|
We hadn't updated the "what is the auto-increment clause" logic for h2 because it wasn't failing for me in the tests we have. The old AUTO_INCREMENT clause was working fine so left it at that vs. putting in a version check. Even using the
example it's working for me. My h2 url is just Changing the logic to use the new |
@rburgst and @0x7d7b could you check if the artifacts from https://github.com/liquibase/liquibase/pull/2372/checks resolves the problem for you? |
@rburgst, Liquibase doesn't try to add quoting to the the clause you have. As a partial raw SQL statement, we don't have the ability to understand what is going on in there so we just pass it as-is to to the database. You'll have to handle the quoting there yourself. |
@nvoxland I can understand that. So please ignore that part. As to the autoincrement. It fails for me with the following JDBC URL
|
@nvoxland I tested your pull request in my environment. The reported problem is now solved by your fix.
It reports:
|
@nvoxland BTW in case this is still relevant my test suites JDBC URL looks like this:
|
Any news on this topic? |
@nvoxland, I discovered two test cases that demonstrate the syntax issues. Both reproduce if you have a JDBC connection that specifies Steps to Reproduce
Actual Results
Expected Results
Test Environment |
|
I think all the questions in this issue have been addressed. The overall problem this issue is handling is the fact that on h2 2.x we need to use GENERATED BY DEFAULT and on 1.x we use AUTO_INCREMENT. #2372 fixes that. Besides that issue, there has been discussion on other unconnected problems which if they were problems should have independent issues for better tracking:
If anyone is seeing any of those 3 issues still, or any other h2 2.x compatibility issues, please open them as separate issues. |
@nvoxland I changed those But still: even when I try #2372 the original bug can still be reproduced. I think it has to do with my JDBC URL. There I use the
|
Following up here, @nvoxland and @0x7d7b. I retested with the following changeset:
Results of Testing
Using @0x7d7b's JDBC URL generated the correct SQL for me on h2 v2.1.210.
Test Environment |
Environment
Liquibase Version: 4.7.0
Database Vendor & Version: H2 2.0.206
Description
When using a liquibase changeset containing primary auto increment keys a wrong create table statement is being generated.
Steps To Reproduce
Have a changeset containing e.g.:
Actual Behavior
That will produce an error like:
Expected/Desired Behavior
I would expect it to generate a proper query like:
The text was updated successfully, but these errors were encountered: