-
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 sequenceExists check that became case sensitive for Postgresql #5911
base: master
Are you sure you want to change the base?
Fix sequenceExists check that became case sensitive for Postgresql #5911
Conversation
…ub.com/davidecavestro/liquibase into davidecavestro-fix-pg-sequence-check-case-sensitivity
Hi @davidecavestro, We appreciate your contribution and would be happy with you creating more PRs that solve issues from our backlog. Although, in this particular case I think the proposed solution is not totally accurate, the reason is if someone creates another sequence with a similar name to the previous one it was created it could match and. For example, if someone prior to deploy a changelog like the one shared in #5832 deployed a changeset like the one below: <changeSet author="me" id="test-foo">
<!-- create a new sequence -->
<createSequence sequenceName="MY_SQ_TEST_FOO"/>
</changeSet> Then, the execution of the below changeset: <changeSet author="me" id="test-bar">
<preConditions onFail="HALT">
<sequenceExists sequenceName="SQ_TEST_FOO"/>
</preConditions>
<createSequence sequenceName="SQ_TEST_BAR"/>
</changeSet> could provide a wrong update output. In my opinion, what we can do for this statement.setString(2, getSequenceName()); from On the other hand, it would be nice if we can add some test coverage to test the provided solution, and as in this case this is a DB specific issue I would recommend you to at least add the Postgres integration test. What you can do is to add the provided example in #5832 to this Please let me know if you have any questions/concerns. Thanks, |
@MalloD12 sure, I'll definitely add some tests. |
@MalloD12 I've sketched a test for the false match and one for the proper match. |
Hi @davidecavestro, Thanks for clarifying. When I saw the ILIKE I instantly thought of its common use with the This PR looks good to me to move forward with it. I'll wait a bit more to let one of our Postgres test executions finish before approving this PR and leaving it in the queue so other members of the team can review/test. Thanks, |
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.
Approved.
Code changes and tests look good to me. Thank you Davide for this PR and for adding test coverage to it.
There are some test (from Test-Harness project) currently failing, but that's not related to the changes made here.
Impact
Description
Fix regression on sequenceExists precondition, which became case sensitive from 4.24 on.
Replaces the equals operator with a ILIKE into the Postgresql specific SQL query defined as constant
SQL_CHECK_POSTGRES_SEQUENCE_EXISTS
, to also match sequences created (and checked for existence) with an uppercase name and automatically converted to lowercase by the dbms.Additional Context
Fixes #5832