microsoft / microsoft/sqlmanagementobjects

SMO is incorrectly defaulting the schema-identifier, when it shouldn't be (e.g. on CREATE PROCEDURE).

Abierto
#174 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
143
Forks
28
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el problema con los scripts de procedimientos almacenados TEST1 y TEST2 y, después, inspecciona las opciones de scripting de SMO y el comportamiento de su API para procedimientos, vistas y UDFs. Compara las definiciones generadas con Schema Compare; se considera terminado cuando un esquema omitido sigue omitiéndose, de modo que los objetos equivalentes no se reporten como diferentes.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp, sql
Área
databases
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.