Skip to content

Commit

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

Fixes #25006
  • Loading branch information
roji committed Jun 1, 2021
1 parent 248e494 commit 3cf4dd9
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 3cf4dd9

Please sign in to comment.