Make TupleIdIsPrimaryKey configurable.
Sean Hall committed
Apr 5, 2020 at 21:28 UTC
494a3f66905381e3f65faefeed7f5224fcf42860
1 file changed
+9
-15
src/WixToolset.Data/WindowsInstaller/TableDefinition.cs
+9
-15
@@ -24,18 +24,9 @@ namespace WixToolset.Data.WindowsInstaller
24
/// <param name="name">Name of table to create.</param>
25
/// <param name="columns">Column definitions for the table.</param>
26
/// <param name="unreal">Flag if table is unreal.</param>
27
- public TableDefinition(string name, IEnumerable<ColumnDefinition> columns, bool unreal = false) : this(name, null, columns, unreal)
28
- {
29
- }
30
-
31
- /// <summary>
32
- /// Creates a table definition.
33
- /// </summary>
34
- /// <param name="name">Name of table to create.</param>
27
/// <param name="tupleDefinitionName">Optional name of tuple definition for this table.</param>
36
- /// <param name="columns">Column definitions for the table.</param>
37
- /// <param name="unreal">Flag if table is unreal.</param>
38
- public TableDefinition(string name, string tupleDefinitionName, IEnumerable<ColumnDefinition> columns, bool unreal = false)
28
+ /// <param name="tupleIdIsPrimaryKey">Whether the primary key is the id of the tuple definition associated with this table.</param>
29
+ public TableDefinition(string name, IEnumerable<ColumnDefinition> columns, bool unreal = false, string tupleDefinitionName = null, bool? tupleIdIsPrimaryKey = null)
30
{
31
this.Name = name;
32
this.TupleDefinitionName = tupleDefinitionName ?? name;
@@ -46,7 +37,7 @@ namespace WixToolset.Data.WindowsInstaller
37
{
38
throw new ArgumentOutOfRangeException(nameof(columns));
39
}
49
- this.TupleIdIsPrimaryKey = DeriveTupleIdIsPrimaryKey(this.Columns);
40
+ this.TupleIdIsPrimaryKey = tupleIdIsPrimaryKey ?? DeriveTupleIdIsPrimaryKey(this.Columns);
41
}
42
43
/// <summary>
@@ -141,7 +132,7 @@ namespace WixToolset.Data.WindowsInstaller
132
string name = null;
133
string tupleDefinitionName = null;
134
var unreal = false;
144
- var bootstrapperApplicationData = false;
135
+ bool? tupleIdIsPrimaryKey = null;
136
137
while (reader.MoveToNextAttribute())
138
{
@@ -153,6 +144,9 @@ namespace WixToolset.Data.WindowsInstaller
144
case "tupleDefinitionName":
145
tupleDefinitionName = reader.Value;
146
break;
147
+ case "tupleIdIsPrimaryKey":
148
+ tupleIdIsPrimaryKey = reader.Value.Equals("yes");
149
+ break;
150
case "unreal":
151
unreal = reader.Value.Equals("yes");
152
break;
@@ -198,7 +192,7 @@ namespace WixToolset.Data.WindowsInstaller
192
}
193
}
194
201
- if (!unreal && !bootstrapperApplicationData && !hasPrimaryKeyColumn)
195
+ if (!unreal && !hasPrimaryKeyColumn)
196
{
197
throw new WixException(ErrorMessages.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name));
198
}
@@ -209,7 +203,7 @@ namespace WixToolset.Data.WindowsInstaller
203
}
204
}
205
212
- return new TableDefinition(name, tupleDefinitionName, columns.ToArray(), unreal);
206
+ return new TableDefinition(name, columns.ToArray(), unreal, tupleDefinitionName, tupleIdIsPrimaryKey);
207
}
208
209
/// <summary>