Skip to content

Commit

Permalink
Scaffold SQL Server index fill factor annotation as int (#25008)
Browse files Browse the repository at this point in the history
To align with metadata APIs.

Fixes #25006
  • Loading branch information
roji committed Jun 2, 2021
1 parent a276b15 commit c09204f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ FROM [sys].[indexes] i

if (indexGroup.Key.FillFactor > 0 && indexGroup.Key.FillFactor <= 100)
{
index[SqlServerAnnotationNames.FillFactor] = indexGroup.Key.FillFactor;
index[SqlServerAnnotationNames.FillFactor] = (int)indexGroup.Key.FillFactor;
}

foreach (var dataRecord in indexGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,33 @@ IncludeProperty int
"DROP TABLE IncludeIndexTable;");
}

[ConditionalFact]
public void Index_fill_factor()
{
Test(
@"
CREATE TABLE IndexFillFactor
(
Id INT IDENTITY,
Name NVARCHAR(100)
);
CREATE NONCLUSTERED INDEX [IX_Name] ON [dbo].[IndexFillFactor]
(
[Name] ASC
)
WITH (FILLFACTOR = 80) ON [PRIMARY]",
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
dbModel =>
{
var index = Assert.Single(dbModel.Tables.Single().Indexes);
Assert.Equal(new[] { "Name" }, index.Columns.Select(ic => ic.Name).ToList());
Assert.Equal(80, index[SqlServerAnnotationNames.FillFactor]);
},
"DROP TABLE IndexFillFactor;");
}

#endregion

#region ForeignKeyFacets
Expand Down

0 comments on commit c09204f

Please sign in to comment.