-
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
Fix #2780: AddColumnChange with schema and NOT NULL constraint fails #2781
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update the AddColumnChange test case to include a non-default schema & catalog, covering those two fields of the AddColumnChange. The changeSet field from the AbstractChange is not covered by the test.
The original implementation delegating the creation of a NOT NULL constraint within the AddColumnChange to the AddNotNullConstraintChange was flawed in that it ignored some properties present both in the ConstraintsConfig and in the AddNotNullConstraintChange.
…I'm not quite certain of the expected outcome.
…iquibase into TheDecker-liquibase-2780-patch
nvoxland
approved these changes
May 2, 2022
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
- Code changes makes sense for the change
- I was able to reproduce the problem before the fix, and see it work after the fix
- I didn't add a test-harness test since I don't think it handles multi-schema tests yet
- Unit test was updated to ensure the schema is passed along if sent
Things to worry about
- Nothing
suryaaki2
approved these changes
May 25, 2022
XDelphiGrl
approved these changes
May 27, 2022
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.
- Fix passes schemaName property to the addNotNullConstraintChange.
- Fix also sets the validate property for addNotNullConstraintChange.
- Unit tests added.
- No additional test required.
APPROVED
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Environment
Liquibase Version: 4.9.1
Liquibase Integration & Version: Spring 5.3.15
Liquibase Extension(s) & Version: none
Database Vendor & Version: H2 1.2.212
Operating System Type & Version: Windows 11
Pull Request Type
Description
Fixes #2780
With commit 3f62f95 the
AddColumnChange
was modified to not include NOT NULL constraints in the initialALTER TABLE ... ADD
statement but instead use an "embedded"AlterColumnChange
to generate anALTER TABLE ... ALTER COLUMN
statement to be executed separately.However when creating that
AlterColumnChange
, the schema property from the originalAddColumnChange
(as well as a number of other properties from the correspondingConstraintsConfig
) are not copied over to the newAlterColumnChange
which means that when using a non-default schema theALTER TABLE ... ALTER COLUMN
targets the wrong schema.Steps To Reproduce
Actual Behavior
Before Liquibase 4.7.0 the above change sets works fine.
Starting with Liquibase 4.7.0 the second change set fails at the SQL statement that is generated to add the NOT NULL constraint:
The non-default schema given in the
addColumn
-Change is obviously not used when generating that statement.Expected/Desired Behavior
The SQL statement generated by the second change set changes to:
This is executed without errors.
Screenshots (if appropriate)
n.a.
Additional Context
n.a.
Fast Track PR Acceptance Checklist:
There are failures in
liquibase.util.csv.CSVReaderTest
andliquibase.util.grammar.SimpleSqlGrammarTest
, but these look unrelated to the modifications to me.All other tests in liquibase-core pass.
existing Unit Test
liquibase-core/src/test/java/liquibase/sqlgenerator/core/AddColumnGeneratorTest.java
has been updated to include the schema property.