DacFx/SchemaComparison isn't correctly comparing schema-identifier on procedures/views/UDFs name/identifiers.
- Dominant language
- C#
- Stars
- 460
- Forks
- 29
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
- SqlPackage or DacFx Version: 162.4.92
- .NET Framework (Windows-only) or .NET Core: .NET Core 8.0
- Environment (local platform and source/target platforms): MacOS, Linux
**Steps to Reproduce:**
Apologies, I originally thought this was an SMO bug (logged [here](https://github.com/microsoft/sqlmanagementobjects/issues/174)), but now I don't think so.
To recreate, create two databases, each with 1x procedure in, like so:
```
CREATE DATABASE LEFT
CREATE PROCEDURE GetServerName AS BEGIN SELECT @@SERVERNAME END
```
```
CREATE DATABASE RIGHT
CREATE PROCEDURE dbo.GetServerName AS BEGIN SELECT @@SERVERNAME END
```
You'll note, in database `RIGHT`, we've added the schema-identifier.
If you run DacFx/`ScriptComparison` against these two databases, it returns with 1x difference. It states that the procedure in `LEFT` has no schema, but the procedure in `RIGHT` has a schema.
This is odd.
According to the documentation for `CREATE PROCEDURE`, if no schema is provided, it will default one. Indeed, for database `LEFT`, if you check `sys.procedures`, the schema is `dbo`/`schema_id=1`.
Note: I have the same problem with views, UDFs, etc.
Question: Can someone please help me understand why `ScriptComparison` is returning a difference? To me, this sure looks like a bug.
**Did this occur in prior versions? If not - which version(s) did it work in?**
I haven't tried in prior versions.
Thank you!
(DacFx/SqlPackage/SSMS/Azure Data Studio)
Contributor guide
Research direction
Start with the DacFx ScriptComparison path and reproduce the issue using the two CREATE DATABASE/CREATE PROCEDURE examples in the report. Compare procedures, views, and UDFs when the schema is omitted versus explicitly set to dbo; done means equivalent identifiers are no longer reported as differences.
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
- 45/100