Skip to content
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 addAutoIncrement startValue and incrementBy support on postgresql #2588

Merged
merged 9 commits into from
May 31, 2022

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Mar 1, 2022

Description

This handles two issues related to the addAutoIncrement tag

Postgresql not respecting startValue and incrementBy

  1. The startValue and incrementBy

A changelog like:

    <changeSet id="1" author="example">
        <createTable tableName="test_table">
            <column name="id" type="int"/>
        </createTable>
    </changeSet>

    <changeSet id="2" author="example">
        <addAutoIncrement  tableName="test_table" columnName="id" incrementBy="2" startWith="10"/>
    </changeSet>

doesn't include the incrementBy or startWith attributes when creating the sequence in postgresql.

4.0+ XSDs doesn't allow defaultOnNull or generationType on addAutoIncrement

These attributes were added in 3.6 for oracle, but not really added to the XSD. They happened to work because there was a problem in the XSD that allowed any attribute in addAutoIncrement, and when we fixed that in 4.0 these attributes stopped working.

This PR adds the two attributes back so they can be used again.

NOTE: It does NOT change the behavior where they are ignored for databases other than oracle, rather than throwing a validation exception. We ignore the behavior since it's oracle-specific functionality and so to preserve cross-database compatibility we don't fail the changelog validation.

Test Harness test: liquibase/liquibase-test-harness#213

- Added missing defaultOnNull and generationType attributes to addAutoIncrement
@nvoxland
Copy link
Contributor Author

nvoxland commented Mar 1, 2022

Code review and test results:

Things to be aware of

  • The incrementBy/startWith change just passes the values along to the existing code which uses them
  • The defaultOnNull/generationType change just allows the XSD to not fail validation, there was no change to the logic in how they are used

Things to worry about

  • Without our test patterns in place yet for "does Change X work against database Y" and "how to test XML->Change" parsing, I couldn't add automated tests for it. The changes are straightforward so fairly safe, so not worth blocking this PR until we can get the larger testing effort further along.

@nvoxland nvoxland linked an issue Mar 1, 2022 that may be closed by this pull request
@kataggart
Copy link
Contributor

@nvoxland this is in ready to merge, but no reviewers requested. Can you please add whomever should review? Thanks!

@kataggart kataggart added this to the NEXT milestone Mar 10, 2022
@nvoxland nvoxland removed their assignment Mar 10, 2022
@nvoxland
Copy link
Contributor Author

Not sure why it was in ready to merge. It should be ready for test now, though.

@github-actions
Copy link

github-actions bot commented Mar 10, 2022

Unit Test Results

  4 512 files  ±0    4 512 suites  ±0   31m 42s ⏱️ - 5m 46s
  4 414 tests ±0    4 200 ✔️ ±0     214 💤 ±0  0 ±0 
52 248 runs  ±0  47 240 ✔️ ±0  5 008 💤 ±0  0 ±0 

Results for commit ba956a9. ± Comparison against base commit a574d1e.

♻️ This comment has been updated with latest results.

@nvoxland nvoxland changed the title Fix addAutoIncrement issues Fix addAutoIncrement startValue and incrementBy support on postgresql Apr 14, 2022
@XDelphiGrl
Copy link
Contributor

Note: This fix changes the XSD.

@XDelphiGrl XDelphiGrl removed their assignment Apr 21, 2022
@XDelphiGrl XDelphiGrl self-assigned this May 5, 2022
@XDelphiGrl
Copy link
Contributor

@nvoxland, I'm moving this one back to development as the test-harness PR is not approved (changes requested).

CC @KushnirykOleh

@XDelphiGrl XDelphiGrl assigned nvoxland and unassigned XDelphiGrl May 5, 2022
@nvoxland nvoxland added the ReleaseMajor Fix needs to be part of an x.y release, not an x.y.z patch release label May 9, 2022
@nvoxland nvoxland removed their assignment May 16, 2022
@nvoxland
Copy link
Contributor Author

@KushnirykOleh fixed up the test harness tests

Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix adds support for two additional attributes on sequences.
    • Impacts Postgres, EDB Postgres and CockroachDB.
  • Test harness extended to validate START WITH and INCREMENT BY for Postgres and EDB.
  • Net-new test CockroachDB harness cases added for all sequence-related Liquibase changeTypes.
  • No further testing necessary.

APPROVED

Test Harness Results
Functional Test Results

@nvoxland nvoxland merged commit 1d15682 into master May 31, 2022
@nvoxland nvoxland deleted the addautoincrement-pgsql-arguments branch May 31, 2022 15:17
@kataggart kataggart added this to the NEXT milestone May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocandidate autoIncrement DBPostgres ReleaseMajor Fix needs to be part of an x.y release, not an x.y.z patch release TypeBug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

addAutoIncrement generated wrong sql
4 participants