ScriptDom does not fill Clustered property even if it was explicitly provided on HASH index
IVNSTN opened this issue · 0 comments
IVNSTN commented
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:
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