diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-04-05 21:28:19 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-04-05 21:32:21 +1000 |
| commit | 494a3f66905381e3f65faefeed7f5224fcf42860 (patch) | |
| tree | 03ebd46c292063d7fb334f45ad51369fd6f1698c /src | |
| parent | 9a128569f6ebf7ed43d57b0ecd4ada5ba8a5585a (diff) | |
| download | wix-494a3f66905381e3f65faefeed7f5224fcf42860.tar.gz wix-494a3f66905381e3f65faefeed7f5224fcf42860.tar.bz2 wix-494a3f66905381e3f65faefeed7f5224fcf42860.zip | |
Make TupleIdIsPrimaryKey configurable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Data/WindowsInstaller/TableDefinition.cs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs index 9740b89b..5a9d2f20 100644 --- a/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs +++ b/src/WixToolset.Data/WindowsInstaller/TableDefinition.cs | |||
| @@ -24,18 +24,9 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 24 | /// <param name="name">Name of table to create.</param> | 24 | /// <param name="name">Name of table to create.</param> |
| 25 | /// <param name="columns">Column definitions for the table.</param> | 25 | /// <param name="columns">Column definitions for the table.</param> |
| 26 | /// <param name="unreal">Flag if table is unreal.</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> | ||
| 35 | /// <param name="tupleDefinitionName">Optional name of tuple definition for this table.</param> | 27 | /// <param name="tupleDefinitionName">Optional name of tuple definition for this table.</param> |
| 36 | /// <param name="columns">Column definitions for the table.</param> | 28 | /// <param name="tupleIdIsPrimaryKey">Whether the primary key is the id of the tuple definition associated with this table.</param> |
| 37 | /// <param name="unreal">Flag if table is unreal.</param> | 29 | public TableDefinition(string name, IEnumerable<ColumnDefinition> columns, bool unreal = false, string tupleDefinitionName = null, bool? tupleIdIsPrimaryKey = null) |
| 38 | public TableDefinition(string name, string tupleDefinitionName, IEnumerable<ColumnDefinition> columns, bool unreal = false) | ||
| 39 | { | 30 | { |
| 40 | this.Name = name; | 31 | this.Name = name; |
| 41 | this.TupleDefinitionName = tupleDefinitionName ?? name; | 32 | this.TupleDefinitionName = tupleDefinitionName ?? name; |
| @@ -46,7 +37,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 46 | { | 37 | { |
| 47 | throw new ArgumentOutOfRangeException(nameof(columns)); | 38 | throw new ArgumentOutOfRangeException(nameof(columns)); |
| 48 | } | 39 | } |
| 49 | this.TupleIdIsPrimaryKey = DeriveTupleIdIsPrimaryKey(this.Columns); | 40 | this.TupleIdIsPrimaryKey = tupleIdIsPrimaryKey ?? DeriveTupleIdIsPrimaryKey(this.Columns); |
| 50 | } | 41 | } |
| 51 | 42 | ||
| 52 | /// <summary> | 43 | /// <summary> |
| @@ -141,7 +132,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 141 | string name = null; | 132 | string name = null; |
| 142 | string tupleDefinitionName = null; | 133 | string tupleDefinitionName = null; |
| 143 | var unreal = false; | 134 | var unreal = false; |
| 144 | var bootstrapperApplicationData = false; | 135 | bool? tupleIdIsPrimaryKey = null; |
| 145 | 136 | ||
| 146 | while (reader.MoveToNextAttribute()) | 137 | while (reader.MoveToNextAttribute()) |
| 147 | { | 138 | { |
| @@ -153,6 +144,9 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 153 | case "tupleDefinitionName": | 144 | case "tupleDefinitionName": |
| 154 | tupleDefinitionName = reader.Value; | 145 | tupleDefinitionName = reader.Value; |
| 155 | break; | 146 | break; |
| 147 | case "tupleIdIsPrimaryKey": | ||
| 148 | tupleIdIsPrimaryKey = reader.Value.Equals("yes"); | ||
| 149 | break; | ||
| 156 | case "unreal": | 150 | case "unreal": |
| 157 | unreal = reader.Value.Equals("yes"); | 151 | unreal = reader.Value.Equals("yes"); |
| 158 | break; | 152 | break; |
| @@ -198,7 +192,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 198 | } | 192 | } |
| 199 | } | 193 | } |
| 200 | 194 | ||
| 201 | if (!unreal && !bootstrapperApplicationData && !hasPrimaryKeyColumn) | 195 | if (!unreal && !hasPrimaryKeyColumn) |
| 202 | { | 196 | { |
| 203 | throw new WixException(ErrorMessages.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name)); | 197 | throw new WixException(ErrorMessages.RealTableMissingPrimaryKeyColumn(SourceLineNumber.CreateFromUri(reader.BaseURI), name)); |
| 204 | } | 198 | } |
| @@ -209,7 +203,7 @@ namespace WixToolset.Data.WindowsInstaller | |||
| 209 | } | 203 | } |
| 210 | } | 204 | } |
| 211 | 205 | ||
| 212 | return new TableDefinition(name, tupleDefinitionName, columns.ToArray(), unreal); | 206 | return new TableDefinition(name, columns.ToArray(), unreal, tupleDefinitionName, tupleIdIsPrimaryKey); |
| 213 | } | 207 | } |
| 214 | 208 | ||
| 215 | /// <summary> | 209 | /// <summary> |
