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

MSSQL: Throw validation error if "ordered" is specified in createSequence/alterSequence #2549

Merged
merged 1 commit into from Feb 17, 2022

Conversation

nvoxland
Copy link
Contributor

Description

SqlServer does not support an ordered/unordered clause in sequences and so Liquibase should throw a validation error if the user attempts to specify it in either createSequence or alterSequence.

https://docs.microsoft.com/en-us/sql/t-sql/statements/create-sequence-transact-sql?view=sql-server-ver15

Fixes #2528

@nvoxland
Copy link
Contributor Author

I did not add an automated test because the change simply adds to the configuration of CreateSequenceGenerator and AlterSequenceGenerator vs. adding new logic. I'm working on a better way to be able to capture the configuration details in tests but do not have that ready, and this one-off check seems unuseful.

@nvoxland
Copy link
Contributor Author

NOTE: For users who have ordered=false in their changelog currently, it will be a breaking change because their changelogs will now fail validation.

That seems expected because they are telling us they want to say they can be unordered, and we can't give that to them and should tell them that. It seems unlikely that people will be many people will be setting ordered=false in sqlserver.

It won't be a problem for mssql users who had ordered=true in their changelog, because previously that would have thrown a SQL exception and now it throws a validation exception. So it's not breaking something that worked before, it just gives a better error.

@yodzhubeiskyi
Copy link
Contributor

Manual Testing
Setup
Use next changelog:

    	<changeSet id="1" author="Liquibase" labels="setup">
    		<createSequence sequenceName="SETUP_SEQUENCE" startValue="1" incrementBy="1"/>
  	</changeSet>

	<changeSet id="2" author="Liquibase" labels="create">
    		<createSequence sequenceName="TEST_SEQUENCE" startValue="1" incrementBy="1" ordered="true" />
  	</changeSet>

	<changeSet id="3" author="Liquibase" labels="alter">
    		<alterSequence sequenceName="SETUP_SEQUENCE" ordered="true" />
  	</changeSet>

Run liquibase update --changelog-file changelog.xml --labels setup against MSSQL database

Test Cases
Verify update shows correct error message for createSequence tag with ordered attribute

  • liquibase --changelog-file changelog.xml --labels create
  • ordered is not allowed on mssql error message is shown

Verify update shows correct error message for alterSequence tag with ordered attribute

  • liquibase --changelog-file changelog.xml --labels alter
  • ordered is not allowed on mssql error message is shown

@yodzhubeiskyi
Copy link
Contributor

Test Results
Verify update shows correct error message for createSequence tag with ordered attribute. PASS

Unexpected error running Liquibase: Validation Failed:
     1 changes have validation failures
          ordered is not allowed on mssql, pr2549-changelog.xml::2::Liquibase

Verify update shows correct error message for alterSequence tag with ordered attribute. PASS

Unexpected error running Liquibase: Validation Failed:
     1 changes have validation failures
          ordered is not allowed on mssql, pr2549-changelog.xml::3::Liquibase

Liquibase version [Core: //mssql-no-ordered/1544/0e92b5/2022-02-16 22:00+0000, Pro: master/591/f653ec/2022-02-09T18:09:13Z] #1544

@nvoxland nvoxland merged commit 6cdea2e into master Feb 17, 2022
@nvoxland nvoxland deleted the mssql-no-ordered branch February 17, 2022 23:12
@nvoxland nvoxland added this to the v4.8.0 milestone Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ORDER keyword for sequences is not supported by mssql
3 participants