Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

ScriptDom parses table-level constraint after the last column as column-level constraint if not preceded by comma separator

Open
#72 1 comment 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
sql
Domain
compilers

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

sql-feature

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:
image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/SqlScriptDOM

All issues in microsoft/SqlScriptDOM

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.