-
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 missing attributes in serialization #2585
Conversation
liquibase-core/src/main/java/liquibase/changelog/ChangeSet.java
Outdated
Show resolved
Hide resolved
setAlwaysRun setRunOnChange setRunInTransaction
Code Review and test results: Things to be aware of
Things to worry about
|
Hello, @tms-91! Thanks for the PR! Is the reason we do not have a test for the formatted SQL changelog because there is no serializer for the "raw" SQL format? @nvoxland, hi - Why wouldn't this code be used by the CLI? I am able to add |
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.
Looks good.
@XDelphiGrl Liquibase uses XMLChangeLogSerializer to generate the XML from constructed changelogs, but we don't set runOrder, ignore, or runInTransaction to the changesets we generate. So there isn't a way from our code (currently) for them to get set. |
UPDATE
(start of original comment)
Then update-sql will show that the second changeset runs first (as set in runOrder) and the first changeset runs last (again, in runOrder). The third changeset is entirely ignored. When you update, the changes run in the order shown by update-sql:
I don't know how to validate I'm testing with a feature branch that is (relatively) up-to-date with liquibase/liquibase master. I believe this test should be executed against this PR's build to ensure that there are no regressions (at least for |
Hello @XDelphiGrl ! Thanks for reviewing this PR. From a quick glance at the code it doesn't seem to me that the FormattedSqlChangeLogSerializer uses the getSerializableFields() method of ChangeSet, so there should be no changes in behaviour here. I might have overlooked something though. There should also be no changes to the parsing (reading of changelogs) since ChangeSet does not extend AbstractLiquibaseSerializable and implements its own load and serialize (stub in case of serialize) methods. The load method of ChangeSet doesnt use the getSerializableFields method either and is unchanged. An example use case that would be affected (and fixed) by this PR is the conversion between different Changelog file formats by using Liquibase as a library (not cli):
In this case, without this PR, if a changeset had "runInTransaction", "runOrder", or "ignore" set to non-default values, they would be missing in the generated output changeset and treated as if they had default values, which would alter the semantics of the changeset. |
Hello, @tms-91! Thank you for the excellent explanations in response to my questions. Based on your answers, I will move this ticket to Ready to Merge & you should see your fix in the next release. It makes my day to hear from someone in the Community - thank you for that! |
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.
- Changes impact consumers of Liquibase as a library.
- No impact to the CLI or other integrations.
- Tests added for each of the serializable changelog formats (XML, JSON, YAML).
- Formatted SQL changelogs are not impacted by this fix.
- @tms-91 is an excellent collaborator. As a QA, I love Devs who take the time to explain the code to me.
APPROVED
Agreed, thank you @tms-91! |
Environment
Liquibase Version: 4.7.1+
Liquibase Integration & Version: CLI and Java API
Liquibase Extension(s) & Version: none
Database Vendor & Version: H2 2.1 and MSSQL
Operating System Type & Version: Windows 10
Pull Request Type
Description
The ChangeSet attributes "runInTransaction", "runOrder" and "ignore" were never serialized since they were missing in the serializableFields list.
Steps To Reproduce
Actual Behavior
After exporting the ChangeLog again the attributes "runInTransaction", "runOrder" and "ignore" are missing on the ChangeSet.
Expected/Desired Behavior
The ChangeSet retaining the attributes "runInTransaction", "runOrder" and "ignore" after export.
Screenshots (if appropriate)
Additional Context
Fast Track PR Acceptance Checklist:
extended already existing Tests
Need Help?
Come chat with us on our discord channel