ScriptDom parses table-level constraint after the last column as column-level constraint if not preceded by comma separator
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start by reproducing the supplied CREATE TABLE statement with ScriptDom version 161.8919.0 at compatibility level 150, then inspect how the AST classifies the PRIMARY KEY constraint. Done means the constraint is represented as a table-level constraint on bar and far rather than as a column-level constraint linked to zar.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- GAP
- Stars
- 277
- Forks
- 43
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/SqlScriptDOM
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
microsoft/SqlScriptDOM#226 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
microsoft/SqlScriptDOM#224 ·
All issues in microsoft/SqlScriptDOM
Similar issues
-
todo:perf
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
objectionary/eo#8894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
objectionary/phie#154 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
objectionary/jeo-maven-plugin#1774 ·
-
Minor breakage w/ LLVM 7: `test_llvm.cpp: error: cannot convert 'llvm::Module' to 'llvm::Module*'` Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100