Fix a bug where virtual columns were created from other tables

This commit is contained in:
Jonathan Jenne 2022-04-08 10:27:17 +02:00
parent b6801ab486
commit 8180c65ccd

View File

@ -259,21 +259,25 @@ Namespace Templates
End Function End Function
Private Function CreateVirtualColumns(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template Private Function CreateVirtualColumns(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template
For Each oConfigItem In pTemplateConfig.Items Dim oTemplateItems = pTemplateConfig.Items.
Where(Function(item) item.Template = pTemplate.Name).
ToList()
For Each oItem In oTemplateItems
' Find the table that relates to this config item ' Find the table that relates to this config item
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oConfigItem.Table).FirstOrDefault() Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oItem.Table).FirstOrDefault()
If oTable Is Nothing Then If oTable Is Nothing Then
Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oConfigItem.Table, oConfigItem.Name) Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oItem.Table, oItem.Name)
Continue For Continue For
End If End If
Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oConfigItem.Name) Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oItem.Name)
If oColumnExists = False And oConfigItem.IsVirtual = True Then If oColumnExists = False And oItem.IsVirtual = True Then
oTable.Columns.Add(New Template.Column() With { oTable.Columns.Add(New Template.Column() With {
.Name = oConfigItem.Name, .Name = oItem.Name,
.Config = oConfigItem, .Config = oItem,
.DataType = Constants.ColumnType.String, .DataType = Constants.ColumnType.String,
.IsRequired = False .IsRequired = False
}) })