Skip to content

Commit

Permalink
Scaffolding: Handle unknown computed column SQL in model factory
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam committed Nov 7, 2023
1 parent e4ff864 commit 61d0c4b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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,37 @@ 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());

}
}

0 comments on commit 61d0c4b

Please sign in to comment.