Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding: Handle unknown computed column SQL in model factory #32251

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!--
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
-->
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">true</StabilizePackageVersion>
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
<DotNetFinalVersionKind Condition="'$(StabilizePackageVersion)' == 'true'">release</DotNetFinalVersionKind>
<DefaultNetCoreTargetFramework>net8.0</DefaultNetCoreTargetFramework>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,14 @@ protected virtual EntityTypeBuilder VisitColumns(EntityTypeBuilder builder, ICol

if (column.ComputedColumnSql != null)
{
property.HasComputedColumnSql(column.ComputedColumnSql, column.IsStored);
if (column.ComputedColumnSql.Length == 0)
{
property.HasComputedColumnSql();
}
else
{
property.HasComputedColumnSql(column.ComputedColumnSql, column.IsStored);
}
}

if (column.Comment != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3072,4 +3072,36 @@ void AssertNavigations()
}
);
}

[ConditionalFact]
public void Computed_column_when_sql_unknown()
{
var database = new DatabaseModel
{
Tables =
{
new DatabaseTable
{
Database = Database,
Name = "Table",
Columns =
{
IdColumn,
new DatabaseColumn
{
Table = Table,
Name = "Column",
StoreType = "int",
ComputedColumnSql = string.Empty
}
}
}
}
};

var model = _factory.Create(database, new ModelReverseEngineerOptions());

var column = model.FindEntityType("Table").GetProperty("Column");
Assert.Empty(column.GetComputedColumnSql());
}
}
Loading