microsoft / microsoft/sqlmanagementobjects
SMO issue with default column values.
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 143
- Forks
- 28
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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!
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece reproduzindo os casos de CREATE TABLE e ALTER TABLE no SMO e, em seguida, rastreie o caminho de geração de scripts de valores padrão do SMO que produz o SQL gerado. Compare a saída com a definição do banco de dados e o comportamento de DacFx ScriptComparison; considera-se concluído quando valores padrão primitivos, como 10 ou 0, são representados de forma consistente e sem parênteses redundantes.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, sql
- Domínio
- databases
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100