microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
356 stars 20 forks source link

DacFx/SchemaComparison isn't correctly comparing schema-identifier on procedures/views/UDFs name/identifiers. #511

Open sdonovanuk opened 1 month ago

sdonovanuk commented 1 month ago

Steps to Reproduce:

Apologies, I originally thought this was an SMO bug (logged here), 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)