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

Improve renameColumn generated SQL on mssql #783

Merged
merged 5 commits into from Jul 20, 2022

Conversation

mide25
Copy link
Contributor

@mide25 mide25 commented Jul 4, 2018

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'

[ , [ @objtype = ] 'object_type' ]

https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=sql-server-2017

Fixes CORE-3276

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
@mide25 mide25 changed the title Update to RenameColumnGenerator.generateSql CORE-3276 Update to RenameColumnGenerator.generateSql Jul 4, 2018
@mide25 mide25 closed this Jul 4, 2018
@mide25 mide25 reopened this Jul 4, 2018
@datical-jenkins datical-jenkins changed the title CORE-3276 Update to RenameColumnGenerator.generateSql LB-119 ⁃ CORE-3276 Update to RenameColumnGenerator.generateSql Mar 4, 2020
@datical-jenkins datical-jenkins changed the title LB-119 ⁃ CORE-3276 Update to RenameColumnGenerator.generateSql LB-119 ⁃ CORE-3276 Update to RenameColumnGenerator.generateSql Mar 4, 2020
@datical-jenkins datical-jenkins changed the title LB-119 ⁃ CORE-3276 Update to RenameColumnGenerator.generateSql CORE-3276 Update to RenameColumnGenerator.generateSql Mar 5, 2020
@ro-rah
Copy link

ro-rah commented May 13, 2020

@mide25

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.

@ro-rah
Copy link

ro-rah commented May 13, 2020

@mide25 would you be willing to add unit or integration tests for this change?

Till then I will size at a Medium.

@ro-rah ro-rah added RiskMedium Changes that require more testing or that affect many different code paths. StatusConditioning and removed StatusDiscovery labels May 13, 2020
@liquibot
Copy link
Contributor

➤ 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]
CC: [~accountid:5d937e71f5d3c10d8bfd351d]

@nvoxland
Copy link
Contributor

It is a slightly better version of the existing sql. The existing integration tests should catch if it's a problem

@liquibot liquibot added RiskLow Trivial changes in spelling, documentation changes, focused bug fixes, etc. and removed RiskMedium Changes that require more testing or that affect many different code paths. labels May 27, 2020
@liquibot
Copy link
Contributor

liquibot commented Jun 4, 2020

➤ Erzsebet Carmean commented:

Thank you for the response, Nathan! -erz (@ XDelphiGrl)

CC : [~accountid:557058:c8f0b24d-f02f-431c-8842-fd9c929dfbf2]

@michaelplavnik
Copy link

michaelplavnik commented Feb 10, 2021

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.

@molivasdat
Copy link
Contributor

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.

@kataggart kataggart added this to To Do in Conditioning++ via automation Jul 5, 2022
@kataggart
Copy link
Contributor

@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!

@nvoxland nvoxland added the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label Jul 12, 2022
@github-actions
Copy link

github-actions bot commented Jul 12, 2022

Unit Test Results

  4 608 files  ±0    4 608 suites  ±0   31m 41s ⏱️ - 4m 46s
  4 589 tests ±0    4 375 ✔️ ±0     214 💤 ±0  0 ±0 
54 240 runs  ±0  49 232 ✔️ ±0  5 008 💤 ±0  0 ±0 

Results for commit 7b2c9f5. ± Comparison against base commit bcd2d53.

♻️ This comment has been updated with latest results.

@nvoxland nvoxland added SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions and removed SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions labels Jul 13, 2022
@nvoxland nvoxland added SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions and removed SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions labels Jul 13, 2022
@nvoxland nvoxland added SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions and removed SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions labels Jul 14, 2022
@nvoxland nvoxland requested a review from XDelphiGrl July 15, 2022 17:48
@nvoxland
Copy link
Contributor

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:

  • Existing tests call renameColumn on mssql and continue to pass

Things to worry about:

  • Nothing

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.

  • Targeted fix for renaming a SQL Server column.
  • New unit test added.
  • No additional testing required.

APPROVED

Passing Functional Tests
Passing Test Harness Execution

@nvoxland nvoxland merged commit 3d3f827 into liquibase:master Jul 20, 2022
Conditioning++ automation moved this from To Do to Done Jul 20, 2022
@kataggart kataggart added this to the NEXT milestone Jul 20, 2022
@nvoxland nvoxland changed the title CORE-3276 Update to RenameColumnGenerator.generateSql Improve renameColumn generated SQL on mssql Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocandidate DBMSSQLServer RiskLow Trivial changes in spelling, documentation changes, focused bug fixes, etc. SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions sprint2022-29 TypeBug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

10 participants