microsoft / microsoft/sqlmanagementobjects
SMO issue with default column values.
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
Greetings. To reproduce. . .
Create the following table:
CREATE TABLE DefaultTest (
[FlagValue] INT DEFAULT 10
)
Then, generate the SMO script. You will get:
CREATE TABLE [dbo].[DefaultTest] (
[FlagValue] INT DEFAULT ((10)) NULL
);
This is odd, why has the 10 become ((10))? Syntax wise, 10 is OK.
The same happens if you create the table without the default, then add it with:
ALTER TABLE DefaultTest ADD DEFAULT 10 FOR [FlagValue]
What's interesting, is that if you use Azure Data Studio to edit the ((10)) default value in the UI back to 10 (maybe the UI isn't using SMO?), the SQL it generates displays as:
CREATE TABLE [dbo].[DefaultTest] (
[FlagValue] INT DEFAULT 10 NULL
);
. . . which instantly becomes ((10)) again when you apply the change to the database.
Now, the engine always stores the constraints definition wrapped with ( and ).
I contend there is a bug in SMO -- if the value within parenthesis is a primitive (string, integer, etc), then it doesn't need parenthesis.
Why is this a problem? Currently writing code to compare schemas against two databases, and having to parse weird output from DacFx's ScriptComparison, which is complaining that default values of (0) sometimes become ((0)). Now, I can write an AST parser using ScriptDom, but isn't this an SMO error?
Basically, it means that SMO isn't generating a technically identical representation of the table.
Thanks!
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza reproduciendo los casos de CREATE TABLE y ALTER TABLE en SMO; después, sigue la ruta de generación de scripts de valores predeterminados de SMO que produce el SQL generado. Compara la salida con la definición de la base de datos y el comportamiento de DacFx ScriptComparison; se considera terminado cuando los valores predeterminados primitivos, como 10 o 0, se representan de forma coherente y sin paréntesis redundantes.
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
- 38/100