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

ScriptDom does not fill Clustered property even if it was explicitly provided on HASH index

Open
#73 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, sql
Domain
databases, tooling

Research direction

Start by parsing the supplied CREATE TABLE statement with ScriptDOM and inspect the primary-key node's Clustered property. Compare the result for the explicit NONCLUSTERED HASH declaration; the issue is done when that property is false instead of null for this case.

Written by the indexing model from the issue text.

Description

ScriptDom version: 161.8919.0
Compatibility level used for parsing: 150

Parser did not fill Clustered property and because it is a PRIMARY KEY which are CLUSTERED by default unless explicitly defined as NONCLUSTERED, I resolved this case in my code as implicitly clustered. However it is clearly explicitly NONCLUSTERED. I think Clustered property should be false in this case.

CREATE TABLE dbo.foo
(
    bar VARCHAR(512)   NOT NULL
    , far VARCHAR(20)    NULL
    , CONSTRAINT PK PRIMARY KEY NONCLUSTERED HASH (bar) WITH (BUCKET_COUNT = 500000)
    , INDEX IX_2 NONCLUSTERED HASH (far)
          WITH (BUCKET_COUNT = 500000)
)
WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);
GO

Here are object properties for PK node:
image

So to check if index is clustered with respect to property nullability one has to do something like that:

bool isClustered;
if (node.Clustered.HasValue)
{
    isClustered = node.Clustered.Value;
}
else if (node.IndexType != null && node.IndexType.IndexTypeKind.HasValue)
{
    isClustered = node.IndexType.IndexTypeKind.Value == IndexTypeKind.Clustered
        || node.IndexType.IndexTypeKind.Value == IndexTypeKind.ClusteredColumnStore;
}
else
{
    isClustered = node.IsPrimaryKey;
}

feels like it could be more straightforward

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 Databases issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.