Unexpected behavior of CONSTRAINT DEFAULT CAST(0 AS BIT) in dacpac converted to CONVERT([bit],(0) in target DB
- Dominant language
- C#
- Stars
- 460
- Forks
- 29
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
- SqlPackage or DacFx Version: Both
- .NET Framework (Windows-only) or .NET Core: Both
- Environment (local platform and source/target platforms): All
**Steps to Reproduce:**
1. Create a database and create a table (below syntax) in SSMS
`2.CREATE TABLE [dbo].[Demo] (
[DemoId] INT IDENTITY (1, 1) NOT NULL,
[Field1] BIT CONSTRAINT [Field1Constraint] DEFAULT CAST(0 AS BIT) NOT NULL
);`
3. When script out the created the table, you can observe the CAST(0 AS BIT) changes to CONVERT([bit],(0)).
4. Since both are same according to the engine, but dacfx fails to recognize them and generated the differences, which might cause drop and recreating then column/ater table/ rebuild as well in some scenarios.
**Did this occur in prior versions? If not - which version(s) did it work in?**
(DacFx/SqlPackage/SSMS/Azure Data Studio) All
Contributor guide
Research direction
Reproduce the issue using the provided CREATE TABLE statement and the SqlPackage or DacFx workflow, then compare the scripted CAST(0 AS BIT) with the generated CONVERT([bit],(0)). Trace where DacFx compares these default constraints; done means equivalent expressions no longer produce a schema difference or unnecessary column/table rebuild.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100