ScriptDom parses table-level constraint after the last column as column-level constraint if not preceded by comma separator
还没有人认领这个 Issue。
评估
调研方向
首先,使用 ScriptDom version 161.8919.0 在 compatibility level 150 下复现所提供的 CREATE TABLE 语句,然后检查 AST 如何对 PRIMARY KEY constraint 进行分类。完成的标准是:该 constraint 被表示为 bar 和 far 上的 table-level constraint,而不是与 zar 关联的 column-level constraint。
由索引模型根据 Issue 内容生成。
描述
In this code sample:
CREATE TABLE dbo.foo
(
bar INT NOT NULL DEFAULT 0
, far VARCHAR(100) NOT NULL
, zar DATE PRIMARY KEY (bar, far)
)
comma separator is missing before PRIMARY KEY constraint declaration. And ScriptDom parses it as a column-level constraint linked to zar column which is wrong. Note, in such case column-level constraint has columns property with different columns listed. It should be parsed as table level constraint.
The syntax brings some ambiguity however it is completely valid. For created table sp_help shows no constraint for column zar and shows table-level unnamed PRIMARY KEY constraint on bar and far columns:
While developing rules for our custom T-SQL linter with columns declared as inline primary key involved, I have to double check if the inline PK is actually related to analyzed column. It would be great if such table-level constraints were parsed exactly as table-level constraints, not column-level.
ScriptDom version: 161.8919.0
Compatibility level used for parsing: 150
- 主要语言
- GAP
- 星标
- 277
- 派生
- 43
- 平均合并
- 6 天 17 小时
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/SqlScriptDOM 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/SqlScriptDOM#228 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
microsoft/SqlScriptDOM#183 ·
-
难度 4/5 3-5 天 新手友好度 56/100
microsoft/SqlScriptDOM#226 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 48/100
microsoft/SqlScriptDOM#225 ·
-
难度 3/5 1-2 天 新手友好度 58/100
microsoft/SqlScriptDOM#224 ·
查看 microsoft/SqlScriptDOM 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
oxc-project/oxc#26944 ·