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
Improve renameColumn generated SQL on mssql #783
Conversation
Mssql fix to follow syntax as per msdn: sp_rename [ @OBJName = ] 'object_name' , [ @NewName = ] 'new_name' [ , [ @objtype = ] 'object_type' ] https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=sql-server-2017
Thanks for your pull request! Here’s what happens next: A member of the Liquibase team will take a look at your contribution and may suggest:
The PR will be prioritized according to our internal development and testing capacity. We’ll let you know when it’s ready to move to the next step or if any changes are needed. |
@mide25 would you be willing to add unit or integration tests for this change? Till then I will size at a Medium. |
➤ Erzsebet Carmean commented: I'm flagging this for internal discussion of repro steps and type of testing. This looks like it could fall into a unit test rather than a full e2e functional test. -erz (@ XDelphiGrl) CC : [~accountid:557058:c8f0b24d-f02f-431c-8842-fd9c929dfbf2] |
It is a slightly better version of the existing sql. The existing integration tests should catch if it's a problem |
➤ Erzsebet Carmean commented: Thank you for the response, Nathan! -erz (@ XDelphiGrl) CC : [~accountid:557058:c8f0b24d-f02f-431c-8842-fd9c929dfbf2] |
Please include this PR into closest release, as it fixes another severe issue, rename of the colum on system versioned table. Without explicitely specifying 'COLUMN' object type parameter, rename will affect primary table, but will not touch version table. Today it causes liquibase users to put verbose SQL server specific SQL to workaround. |
HI @michaelplavnik Thanks for letting us know that this is still a priority. We will look to add it soon. It did not make 4.3 or 4.3.1. |
@nvoxland looks like back in the day you reviewed this and approved it, but given it's age It likely needs a re-review and a re-build. Thanks! |
Code review and test results: Change makes sense, it adds an extra and helpful argument to the rename call to better handle the defined bug. Things to be aware of:
Things to worry about:
|
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.
- Targeted fix for renaming a SQL Server column.
- New unit test added.
- No additional testing required.
APPROVED
Overview
The existing rename column logic on mssql does not specify it is a column that is being renamed. This works fine as long as there are not objects of other types in the database with the same name.
The fix updates the SQL to explicitly say way are updating a column to avoid the abiguity.
Fix details
Mssql fix to follow syntax as per msdn:
sp_rename [ objname = ] 'object_name' , [ newname = ] 'new_name'
https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=sql-server-2017
Fixes CORE-3276