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

Not Null Persisted Computed Column Permanent Schema Diff #500

Open
asrichesson opened this issue Sep 30, 2024 · 0 comments
Open

Not Null Persisted Computed Column Permanent Schema Diff #500

asrichesson opened this issue Sep 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@asrichesson
Copy link

  • SqlPackage or DacFx Version: 162.4.92.3
  • .NET Framework (Windows-only) or .NET Core: both
  • Environment (local platform and source/target platforms): Microsoft SQL Server 2019 (RTM-CU27-GDR) (KB5040948) - 15.0.4382.1 (X64) Jul 1 2024 20:03:23 Copyright (C) 2019 Microsoft Corporation Express Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 22631: ) (Hypervisor)

Steps to Reproduce:

  1. Create a table definition in a sqlproj
CREATE TABLE [dbo].[MyTable](    
    NormalColumn INT NOT NULL,
    ComputedColumn AS NormalColumn PERSISTED,
) ON [PRIMARY]
  1. Build and deploy this as a dacpac
  2. The computed column is dropped and recreated when it shouldn't be
ALTER TABLE [dbo].[MyTable] DROP COLUMN [ComputedColumn];

ALTER TABLE [dbo].[MyTable] ADD [ComputedColumn] AS NormalColumn PERSISTED;

Similar examples:
This does not result in a column drop and create

CREATE TABLE [dbo].[MyTable](    
    NormalColumn INT NULL,
    ComputedColumn AS NormalColumn PERSISTED,
) ON [PRIMARY]

Neither does this:

CREATE TABLE [dbo].[MyTable](    
    NormalColumn INT NOT NULL,
    ComputedColumn AS NormalColumn,
) ON [PRIMARY]

And neither does this

CREATE TABLE [dbo].[MyTable](    
    NormalColumn INT NOT NULL,
    ComputedColumn AS NormalColumn PERSISTED NOT NULL,
) ON [PRIMARY]

It seems to be a combination of the NOT NULL and PERSISTED

Did this occur in prior versions? If not - which version(s) did it work in?

(DacFx/SqlPackage/SSMS/Azure Data Studio)

@asrichesson asrichesson added the bug Something isn't working label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant