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

liquibase 4.25.0 mssql server case sensitive issue with sys.sp_updateextendedproperty #5754

Open
1 of 2 tasks
Aboruhen opened this issue Apr 2, 2024 · 0 comments
Open
1 of 2 tasks

Comments

@Aboruhen
Copy link

Aboruhen commented Apr 2, 2024

Search first

  • I searched and no similar issues were found

Description

Hi,
While migrating from MsSql DB version 2017 to newer 2019 or 2022 we find an issue with add/update table column comments.
So when using the docker DB image: mcr.microsoft.com/mssql/server:2019-CU21-ubuntu-20.04 with a default collation the change log executes normally

<setColumnRemarks tableName="test" columnName="id" remarks="some new comment"/>

In case we config DB with MSSQL_COLLATION: Latin1_General_CS_AS_KS
The same changelog fails with an error:

Caused by: liquibase.exception.DatabaseException: Property cannot be added. Property 'MS_Description' already exists for 'dbo.test.id'. [Failed SQL: (15233) IF EXISTS(  SELECT extended_properties.value FROM sys.extended_properties WHERE major_id = OBJECT_ID('dbo.test') AND name = N'MS_DESCRIPTION' AND minor_id = ( SELECT column_id FROM sys.columns WHERE name = 'id' AND object_id = OBJECT_ID('dbo.test')) ) BEGIN  EXEC sys.sp_updateextendedproperty @name = N'MS_Description' , @value = N'some new comment' , @level0type = N'SCHEMA' , @level0name = N'dbo' , @level1type = N'TABLE' , @level1name = test' , @level2type = N'COLUMN' , @level2name = N'id' END  ELSE  BEGIN  EXEC sys.sp_addextendedproperty @name = N'MS_Description' , @value = N'some new comment' , @level0type = N'SCHEMA' , @level0name = N'dbo' , @level1type = N'TABLE' , @level1name = N'test' , @level2type = N'COLUMN' , @level2name = N'id' END;]
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:470)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:77)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:179)
        at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1291)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Property cannot be added. Property 'MS_Description' already exists for 'dbo.test.id'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259)

NOTE: an error appears only in case of updating. If the column didn't have the comment new remarks is set normally.

Steps To Reproduce

Create 2 sequences of the changeset. Create any column with comments and for a second create the changelog where you try to set a new column comment via

<setColumnRemarks tableName="test" columnName="description"
            remarks="New description column comment"/>

Expected/Desired Behavior

The column comment should be updated with any type of DB collation

Liquibase Version

No response

Database Vendor & Version

MsSql 2019

Liquibase Integration

No response

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants