SMO issue with default column values.
還沒有人認領這個 Issue。
評估
研究方向
先在 SMO 中重現 CREATE TABLE 和 ALTER TABLE 的情況,然後追蹤產生 SQL 的 SMO 預設值指令碼路徑。將輸出與資料庫定義以及 DacFx ScriptComparison 的行為進行比較;當 10 或 0 等原始預設值能以一致的方式表示且沒有多餘的括號時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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!
- 主要語言
- C#
- 星號
- 143
- 分支
- 28
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/sqlmanagementobjects 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
-
難度 3/5 1-2 天 新手友好度 72/100
-
難度 4/5 3-5 天 新手友好度 74/100
-
難度 3/5 1-2 天 新手友好度 78/100
-
難度 3/5 1-2 天 新手友好度 68/100
查看 microsoft/sqlmanagementobjects 的全部 Issue
相似的 Issue
-
effort:S P3 refactor
難度 2/5 1-3 小時 新手友好度 75/100
nightscout/nocturne#1532 ·
-
core dependencies
難度 1/5 1 小時以內 新手友好度 80/100
-
documentation
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
DotNetNext/SqlSugar#1458 ·