microsoft / microsoft/sqlmanagementobjects
SMO is incorrectly defaulting the schema-identifier, when it shouldn't be (e.g. on CREATE PROCEDURE).
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 143
- Forks
- 28
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Create a database, e.g. TEST1, and create the following stored-procedure:
CREATE PROCEDURE GetServerName AS BEGIN SELECT @@SERVERNAME END
Note: no schema identifier was provided above.
Now, in something like SSMS (or Azure Database Studio), whatever, query the stored-procedure (sp) and it clearly states that it belongs to dbo/schema_id=1.
Now, to exercise SMO, use SSMS (or whatever) and generate the SQL to CREATE the sp, and you'll get:
CREATE PROCEDURE [dbo].[GetServerName] AS BEGIN SELECT @@SERVERNAME END
You'll notice that it's added the schema, [dbo].
I think, that this could actually be a bug. I contend that it shouldn't have added the schema.
Why? Well, apparently it makes a difference . . .
Now, create a second database, e.g. TEST2, and apply the generated sp, then compare, either with (i) Azure Data Studio's "Schema Compare" tool, or (ii) DacFx's SchemaComparison (I assume they are the same thing) and . . . it flags a difference: the SQL it generates for TEST1 doesn't have the schema, but the SQL it generates for TEST2 does have the schema.
My question is: how can I configure SMO options (for calling from C#) to only generate the schema-identifier value it was originally provided (or nothing, if that's the case)? With that, I could run DacFx/SchemaComparison and the two objects would be considered identical.
There could be a little debate as to whether the issue is SMO or DacFx/SchemaComparison, but it seems logical the problem originates in SMO.
Note: the same problem applies to views, UDFs, etc.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Problem mit den gespeicherten Prozedurskripten TEST1 und TEST2 und untersuche anschließend die Scripting-Optionen und das API-Verhalten von SMO für Prozeduren, Ansichten und UDFs. Vergleiche die generierten Definitionen mit Schema Compare; abgeschlossen ist die Aufgabe, wenn ein weggelassenes Schema weiterhin weggelassen wird, sodass gleichwertige Objekte nicht als unterschiedlich gemeldet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, sql
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100