microsoft / microsoft/sqlmanagementobjects
SMO issue with default column values.
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 143
- フォーク
- 28
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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!
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず SMO で CREATE TABLE と ALTER TABLE のケースを再現し、次に生成される SQL を作成する SMO の既定値スクリプト処理パスを追跡します。出力をデータベース定義および DacFx ScriptComparison の動作と比較します。10 や 0 などのプリミティブな既定値が、冗長な括弧なしで一貫して表現されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, sql
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100