From d0d447ad64afdd5956856c4c6b6599f69a522d6b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 13 Apr 2020 11:36:20 +1000 Subject: Change TableDefinition to have TupleDefinition instead of TupleDefinitionName. --- .../WindowsInstaller/TableDefinition.cs | 33 ++++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/WixToolset.Data/WindowsInstaller/TableDefinition.cs') diff --git a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs index 5a9d2f20..7c4a3e9d 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs @@ -22,14 +22,15 @@ namespace WixToolset.Data.WindowsInstaller /// Creates a table definition. /// /// Name of table to create. + /// Optional tuple definition for this table. /// Column definitions for the table. /// Flag if table is unreal. - /// Optional name of tuple definition for this table. /// Whether the primary key is the id of the tuple definition associated with this table. - public TableDefinition(string name, IEnumerable columns, bool unreal = false, string tupleDefinitionName = null, bool? tupleIdIsPrimaryKey = null) + public TableDefinition(string name, IntermediateTupleDefinition tupleDefinition, IEnumerable columns, bool unreal = false, bool tupleIdIsPrimaryKey = false) { this.Name = name; - this.TupleDefinitionName = tupleDefinitionName ?? name; + this.TupleDefinition = tupleDefinition; + this.TupleIdIsPrimaryKey = tupleIdIsPrimaryKey; this.Unreal = unreal; this.Columns = columns?.ToArray(); @@ -37,7 +38,6 @@ namespace WixToolset.Data.WindowsInstaller { throw new ArgumentOutOfRangeException(nameof(columns)); } - this.TupleIdIsPrimaryKey = tupleIdIsPrimaryKey ?? DeriveTupleIdIsPrimaryKey(this.Columns); } /// @@ -47,10 +47,10 @@ namespace WixToolset.Data.WindowsInstaller public string Name { get; } /// - /// Gets the name of the tuple definition associated with this table. + /// Gets the tuple definition associated with this table. /// - /// Name of the tuple definition. - public string TupleDefinitionName { get; } + /// The tuple definition. + public IntermediateTupleDefinition TupleDefinition { get; } /// /// Gets if the table is unreal. @@ -130,9 +130,7 @@ namespace WixToolset.Data.WindowsInstaller { var empty = reader.IsEmptyElement; string name = null; - string tupleDefinitionName = null; var unreal = false; - bool? tupleIdIsPrimaryKey = null; while (reader.MoveToNextAttribute()) { @@ -141,12 +139,6 @@ namespace WixToolset.Data.WindowsInstaller case "name": name = reader.Value; break; - case "tupleDefinitionName": - tupleDefinitionName = reader.Value; - break; - case "tupleIdIsPrimaryKey": - tupleIdIsPrimaryKey = reader.Value.Equals("yes"); - break; case "unreal": unreal = reader.Value.Equals("yes"); break; @@ -203,7 +195,7 @@ namespace WixToolset.Data.WindowsInstaller } } - return new TableDefinition(name, columns.ToArray(), unreal, tupleDefinitionName, tupleIdIsPrimaryKey); + return new TableDefinition(name, null, columns.ToArray(), unreal); } /// @@ -228,14 +220,5 @@ namespace WixToolset.Data.WindowsInstaller writer.WriteEndElement(); } - - private static bool DeriveTupleIdIsPrimaryKey(ColumnDefinition[] columns) - { - return columns[0].PrimaryKey && - columns[0].Type == ColumnType.String && - columns[0].Category == ColumnCategory.Identifier && - !columns[0].Name.EndsWith("_") && - (columns.Length == 1 || !columns.Skip(1).Any(t => t.PrimaryKey)); - } } } -- cgit v1.2.3-55-g6feb