diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 4 | ||||
| -rw-r--r-- | src/wixext/SqlCompiler.cs | 142 | ||||
| -rw-r--r-- | src/wixext/SqlTableDefinitions.cs | 82 | ||||
| -rw-r--r-- | src/wixext/SqlWindowsInstallerBackendExtension.cs | 23 | ||||
| -rw-r--r-- | src/wixext/Tuples/SqlDatabaseTuple.cs | 48 | ||||
| -rw-r--r-- | src/wixext/Tuples/SqlFileSpecTuple.cs | 8 | ||||
| -rw-r--r-- | src/wixext/Tuples/SqlScriptTuple.cs | 48 | ||||
| -rw-r--r-- | src/wixext/Tuples/SqlStringTuple.cs | 38 | ||||
| -rw-r--r-- | src/wixext/WixToolset.Sql.wixext.csproj | 1 | ||||
| -rw-r--r-- | src/wixext/tables.xml | 73 |
10 files changed, 220 insertions, 247 deletions
diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index d7fe74e6..7d51c0fb 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | |||
| @@ -19,8 +19,8 @@ namespace WixToolsetTest.Sql | |||
| 19 | var results = build.BuildAndQuery(Build, "SqlString"); | 19 | var results = build.BuildAndQuery(Build, "SqlString"); |
| 20 | Assert.Equal(new[] | 20 | Assert.Equal(new[] |
| 21 | { | 21 | { |
| 22 | "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t0", | 22 | "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", |
| 23 | }, results.OrderBy(s => s).ToArray()); | 23 | }, results.ToArray()); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | private static void Build(string[] args) | 26 | private static void Build(string[] args) |
diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 3fb33993..22b533de 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs | |||
| @@ -7,6 +7,7 @@ namespace WixToolset.Sql | |||
| 7 | using System.Xml.Linq; | 7 | using System.Xml.Linq; |
| 8 | using WixToolset.Data; | 8 | using WixToolset.Data; |
| 9 | using WixToolset.Extensibility; | 9 | using WixToolset.Extensibility; |
| 10 | using WixToolset.Sql.Tuples; | ||
| 10 | 11 | ||
| 11 | /// <summary> | 12 | /// <summary> |
| 12 | /// The compiler for the WiX Toolset SQL Server Extension. | 13 | /// The compiler for the WiX Toolset SQL Server Extension. |
| @@ -45,8 +46,8 @@ namespace WixToolset.Sql | |||
| 45 | switch (parentElement.Name.LocalName) | 46 | switch (parentElement.Name.LocalName) |
| 46 | { | 47 | { |
| 47 | case "Component": | 48 | case "Component": |
| 48 | string componentId = context["ComponentId"]; | 49 | var componentId = context["ComponentId"]; |
| 49 | string directoryId = context["DirectoryId"]; | 50 | var directoryId = context["DirectoryId"]; |
| 50 | 51 | ||
| 51 | switch (element.Name.LocalName) | 52 | switch (element.Name.LocalName) |
| 52 | { | 53 | { |
| @@ -92,7 +93,7 @@ namespace WixToolset.Sql | |||
| 92 | /// <param name="componentId">Identifier for parent component.</param> | 93 | /// <param name="componentId">Identifier for parent component.</param> |
| 93 | private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) | 94 | private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) |
| 94 | { | 95 | { |
| 95 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 96 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
| 96 | Identifier id = null; | 97 | Identifier id = null; |
| 97 | int attributes = 0; | 98 | int attributes = 0; |
| 98 | string database = null; | 99 | string database = null; |
| @@ -102,7 +103,7 @@ namespace WixToolset.Sql | |||
| 102 | string server = null; | 103 | string server = null; |
| 103 | string user = null; | 104 | string user = null; |
| 104 | 105 | ||
| 105 | foreach (XAttribute attrib in element.Attributes()) | 106 | foreach (var attrib in element.Attributes()) |
| 106 | { | 107 | { |
| 107 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 108 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 108 | { | 109 | { |
| @@ -230,7 +231,7 @@ namespace WixToolset.Sql | |||
| 230 | 231 | ||
| 231 | if (null == id) | 232 | if (null == id) |
| 232 | { | 233 | { |
| 233 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | 234 | id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); |
| 234 | } | 235 | } |
| 235 | 236 | ||
| 236 | if (null == database) | 237 | if (null == database) |
| @@ -252,11 +253,11 @@ namespace WixToolset.Sql | |||
| 252 | this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); | 253 | this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); |
| 253 | } | 254 | } |
| 254 | 255 | ||
| 255 | foreach (XElement child in element.Elements()) | 256 | foreach (var child in element.Elements()) |
| 256 | { | 257 | { |
| 257 | if (this.Namespace == child.Name.Namespace) | 258 | if (this.Namespace == child.Name.Namespace) |
| 258 | { | 259 | { |
| 259 | SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); | 260 | var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); |
| 260 | switch (child.Name.LocalName) | 261 | switch (child.Name.LocalName) |
| 261 | { | 262 | { |
| 262 | case "SqlScript": | 263 | case "SqlScript": |
| @@ -285,7 +286,7 @@ namespace WixToolset.Sql | |||
| 285 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); | 286 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); |
| 286 | } | 287 | } |
| 287 | 288 | ||
| 288 | fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); | 289 | fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); |
| 289 | break; | 290 | break; |
| 290 | case "SqlLogFileSpec": | 291 | case "SqlLogFileSpec": |
| 291 | if (null == componentId) | 292 | if (null == componentId) |
| @@ -297,7 +298,7 @@ namespace WixToolset.Sql | |||
| 297 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); | 298 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); |
| 298 | } | 299 | } |
| 299 | 300 | ||
| 300 | logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); | 301 | logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); |
| 301 | break; | 302 | break; |
| 302 | default: | 303 | default: |
| 303 | this.ParseHelper.UnexpectedElement(element, child); | 304 | this.ParseHelper.UnexpectedElement(element, child); |
| @@ -313,23 +314,25 @@ namespace WixToolset.Sql | |||
| 313 | if (null != componentId) | 314 | if (null != componentId) |
| 314 | { | 315 | { |
| 315 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 316 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
| 316 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); | 317 | this.AddReferenceToInstallSqlData(section, sourceLineNumbers); |
| 317 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); | ||
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | if (!this.Messaging.EncounteredError) | 320 | if (!this.Messaging.EncounteredError) |
| 321 | { | 321 | { |
| 322 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlDatabase", id); | 322 | var tuple = section.AddTuple(new SqlDatabaseTuple(sourceLineNumbers, id) |
| 323 | row.Set(1, server); | 323 | { |
| 324 | row.Set(2, instance); | 324 | Server = server, |
| 325 | row.Set(3, database); | 325 | Instance = instance, |
| 326 | row.Set(4, componentId); | 326 | Database = database, |
| 327 | row.Set(5, user); | 327 | ComponentRef = componentId, |
| 328 | row.Set(6, fileSpec?.Id); | 328 | UserRef = user, |
| 329 | row.Set(7, logFileSpec?.Id); | 329 | FileSpecRef = fileSpec?.Id, |
| 330 | LogFileSpecRef = logFileSpec?.Id, | ||
| 331 | }); | ||
| 332 | |||
| 330 | if (0 != attributes) | 333 | if (0 != attributes) |
| 331 | { | 334 | { |
| 332 | row.Set(8, attributes); | 335 | tuple.Attributes = attributes; |
| 333 | } | 336 | } |
| 334 | } | 337 | } |
| 335 | } | 338 | } |
| @@ -341,9 +344,9 @@ namespace WixToolset.Sql | |||
| 341 | /// <param name="section"></param> | 344 | /// <param name="section"></param> |
| 342 | /// <param name="element">Element to parse.</param> | 345 | /// <param name="element">Element to parse.</param> |
| 343 | /// <returns>Identifier of sql file specification.</returns> | 346 | /// <returns>Identifier of sql file specification.</returns> |
| 344 | private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element) | 347 | private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) |
| 345 | { | 348 | { |
| 346 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 349 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
| 347 | Identifier id = null; | 350 | Identifier id = null; |
| 348 | string fileName = null; | 351 | string fileName = null; |
| 349 | string growthSize = null; | 352 | string growthSize = null; |
| @@ -351,7 +354,7 @@ namespace WixToolset.Sql | |||
| 351 | string name = null; | 354 | string name = null; |
| 352 | string size = null; | 355 | string size = null; |
| 353 | 356 | ||
| 354 | foreach (XAttribute attrib in element.Attributes()) | 357 | foreach (var attrib in element.Attributes()) |
| 355 | { | 358 | { |
| 356 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 359 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 357 | { | 360 | { |
| @@ -388,7 +391,7 @@ namespace WixToolset.Sql | |||
| 388 | 391 | ||
| 389 | if (null == id) | 392 | if (null == id) |
| 390 | { | 393 | { |
| 391 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | 394 | id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); |
| 392 | } | 395 | } |
| 393 | 396 | ||
| 394 | if (null == name) | 397 | if (null == name) |
| @@ -405,22 +408,25 @@ namespace WixToolset.Sql | |||
| 405 | 408 | ||
| 406 | if (!this.Messaging.EncounteredError) | 409 | if (!this.Messaging.EncounteredError) |
| 407 | { | 410 | { |
| 408 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlFileSpec", id); | 411 | var tuple = section.AddTuple(new SqlFileSpecTuple(sourceLineNumbers, id) |
| 409 | row.Set(1, name); | 412 | { |
| 410 | row.Set(2, fileName); | 413 | Name = name, |
| 414 | Filename = fileName, | ||
| 415 | }); | ||
| 416 | |||
| 411 | if (null != size) | 417 | if (null != size) |
| 412 | { | 418 | { |
| 413 | row.Set(3, size); | 419 | tuple.Size = size; |
| 414 | } | 420 | } |
| 415 | 421 | ||
| 416 | if (null != maxSize) | 422 | if (null != maxSize) |
| 417 | { | 423 | { |
| 418 | row.Set(4, maxSize); | 424 | tuple.MaxSize = maxSize; |
| 419 | } | 425 | } |
| 420 | 426 | ||
| 421 | if (null != growthSize) | 427 | if (null != growthSize) |
| 422 | { | 428 | { |
| 423 | row.Set(5, growthSize); | 429 | tuple.GrowthSize = growthSize; |
| 424 | } | 430 | } |
| 425 | } | 431 | } |
| 426 | 432 | ||
| @@ -435,16 +441,16 @@ namespace WixToolset.Sql | |||
| 435 | /// <param name="sqlDb">Optional database to execute script against.</param> | 441 | /// <param name="sqlDb">Optional database to execute script against.</param> |
| 436 | private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) | 442 | private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) |
| 437 | { | 443 | { |
| 438 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 444 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
| 439 | Identifier id = null; | 445 | Identifier id = null; |
| 440 | int attributes = 0; | 446 | int attributes = 0; |
| 441 | bool rollbackAttribute = false; | 447 | var rollbackAttribute = false; |
| 442 | bool nonRollbackAttribute = false; | 448 | var nonRollbackAttribute = false; |
| 443 | string binary = null; | 449 | string binary = null; |
| 444 | int sequence = CompilerConstants.IntegerNotSet; | 450 | var sequence = CompilerConstants.IntegerNotSet; |
| 445 | string user = null; | 451 | string user = null; |
| 446 | 452 | ||
| 447 | foreach (XAttribute attrib in element.Attributes()) | 453 | foreach (var attrib in element.Attributes()) |
| 448 | { | 454 | { |
| 449 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 455 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 450 | { | 456 | { |
| @@ -455,7 +461,7 @@ namespace WixToolset.Sql | |||
| 455 | break; | 461 | break; |
| 456 | case "BinaryKey": | 462 | case "BinaryKey": |
| 457 | binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 463 | binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
| 458 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Binary", binary); | 464 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Binary, binary); |
| 459 | break; | 465 | break; |
| 460 | case "Sequence": | 466 | case "Sequence": |
| 461 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); | 467 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); |
| @@ -466,7 +472,7 @@ namespace WixToolset.Sql | |||
| 466 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); | 472 | this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); |
| 467 | } | 473 | } |
| 468 | sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 474 | sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
| 469 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); | 475 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); |
| 470 | break; | 476 | break; |
| 471 | case "User": | 477 | case "User": |
| 472 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 478 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
| @@ -568,7 +574,7 @@ namespace WixToolset.Sql | |||
| 568 | 574 | ||
| 569 | if (null == id) | 575 | if (null == id) |
| 570 | { | 576 | { |
| 571 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | 577 | id = this.ParseHelper.CreateIdentifier("ssc", componentId, binary, sqlDb); |
| 572 | } | 578 | } |
| 573 | 579 | ||
| 574 | if (null == binary) | 580 | if (null == binary) |
| @@ -589,20 +595,22 @@ namespace WixToolset.Sql | |||
| 589 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | 595 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
| 590 | 596 | ||
| 591 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 597 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
| 592 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); | 598 | this.AddReferenceToInstallSqlData(section, sourceLineNumbers); |
| 593 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); | ||
| 594 | 599 | ||
| 595 | if (!this.Messaging.EncounteredError) | 600 | if (!this.Messaging.EncounteredError) |
| 596 | { | 601 | { |
| 597 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlScript", id); | 602 | var tuple = section.AddTuple(new SqlScriptTuple(sourceLineNumbers, id) |
| 598 | row.Set(1, sqlDb); | 603 | { |
| 599 | row.Set(2, componentId); | 604 | SqlDbRef = sqlDb, |
| 600 | row.Set(3, binary); | 605 | ComponentRef = componentId, |
| 601 | row.Set(4, user); | 606 | ScriptBinaryRef = binary, |
| 602 | row.Set(5, attributes); | 607 | UserRef = user, |
| 608 | Attributes = attributes, | ||
| 609 | }); | ||
| 610 | |||
| 603 | if (CompilerConstants.IntegerNotSet != sequence) | 611 | if (CompilerConstants.IntegerNotSet != sequence) |
| 604 | { | 612 | { |
| 605 | row.Set(6, sequence); | 613 | tuple.Sequence = sequence; |
| 606 | } | 614 | } |
| 607 | } | 615 | } |
| 608 | } | 616 | } |
| @@ -615,16 +623,16 @@ namespace WixToolset.Sql | |||
| 615 | /// <param name="sqlDb">Optional database to execute string against.</param> | 623 | /// <param name="sqlDb">Optional database to execute string against.</param> |
| 616 | private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) | 624 | private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) |
| 617 | { | 625 | { |
| 618 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | 626 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); |
| 619 | Identifier id = null; | 627 | Identifier id = null; |
| 620 | int attributes = 0; | 628 | int attributes = 0; |
| 621 | bool rollbackAttribute = false; | 629 | var rollbackAttribute = false; |
| 622 | bool nonRollbackAttribute = false; | 630 | var nonRollbackAttribute = false; |
| 623 | int sequence = CompilerConstants.IntegerNotSet; | 631 | var sequence = CompilerConstants.IntegerNotSet; |
| 624 | string sql = null; | 632 | string sql = null; |
| 625 | string user = null; | 633 | string user = null; |
| 626 | 634 | ||
| 627 | foreach (XAttribute attrib in element.Attributes()) | 635 | foreach (var attrib in element.Attributes()) |
| 628 | { | 636 | { |
| 629 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 637 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 630 | { | 638 | { |
| @@ -727,7 +735,7 @@ namespace WixToolset.Sql | |||
| 727 | } | 735 | } |
| 728 | 736 | ||
| 729 | sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 737 | sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
| 730 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); | 738 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); |
| 731 | break; | 739 | break; |
| 732 | case "User": | 740 | case "User": |
| 733 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 741 | user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
| @@ -746,7 +754,7 @@ namespace WixToolset.Sql | |||
| 746 | 754 | ||
| 747 | if (null == id) | 755 | if (null == id) |
| 748 | { | 756 | { |
| 749 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | 757 | id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); |
| 750 | } | 758 | } |
| 751 | 759 | ||
| 752 | if (null == sql) | 760 | if (null == sql) |
| @@ -767,22 +775,30 @@ namespace WixToolset.Sql | |||
| 767 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | 775 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
| 768 | 776 | ||
| 769 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it | 777 | // Reference InstallSqlData and UninstallSqlData since nothing will happen without it |
| 770 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); | 778 | this.AddReferenceToInstallSqlData(section, sourceLineNumbers); |
| 771 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); | ||
| 772 | 779 | ||
| 773 | if (!this.Messaging.EncounteredError) | 780 | if (!this.Messaging.EncounteredError) |
| 774 | { | 781 | { |
| 775 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlString", id); | 782 | var tuple = section.AddTuple(new SqlStringTuple(sourceLineNumbers, id) |
| 776 | row.Set(1, sqlDb); | 783 | { |
| 777 | row.Set(2, componentId); | 784 | SqlDbRef = sqlDb, |
| 778 | row.Set(3, sql); | 785 | ComponentRef = componentId, |
| 779 | row.Set(4, user); | 786 | SQL = sql, |
| 780 | row.Set(5, attributes); | 787 | UserRef = user, |
| 788 | Attributes = attributes, | ||
| 789 | }); | ||
| 790 | |||
| 781 | if (CompilerConstants.IntegerNotSet != sequence) | 791 | if (CompilerConstants.IntegerNotSet != sequence) |
| 782 | { | 792 | { |
| 783 | row.Set(6, sequence); | 793 | tuple.Sequence = sequence; |
| 784 | } | 794 | } |
| 785 | } | 795 | } |
| 786 | } | 796 | } |
| 797 | |||
| 798 | private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) | ||
| 799 | { | ||
| 800 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "InstallSqlData"); | ||
| 801 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "UninstallSqlData"); | ||
| 802 | } | ||
| 787 | } | 803 | } |
| 788 | } | 804 | } |
diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs new file mode 100644 index 00000000..e980aaae --- /dev/null +++ b/src/wixext/SqlTableDefinitions.cs | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Sql | ||
| 4 | { | ||
| 5 | using WixToolset.Data.WindowsInstaller; | ||
| 6 | |||
| 7 | public static class SqlTableDefinitions | ||
| 8 | { | ||
| 9 | public static readonly TableDefinition SqlDatabase = new TableDefinition( | ||
| 10 | "SqlDatabase", | ||
| 11 | new[] | ||
| 12 | { | ||
| 13 | new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), | ||
| 14 | new ColumnDefinition("Server", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of server running SQL Server"), | ||
| 15 | new ColumnDefinition("Instance", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of SQL Server instance"), | ||
| 16 | new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), | ||
| 17 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), | ||
| 18 | new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), | ||
| 19 | new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), | ||
| 20 | new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), | ||
| 21 | new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), | ||
| 22 | }, | ||
| 23 | tupleDefinitionName: "SqlDatabase", | ||
| 24 | tupleIdIsPrimaryKey: true | ||
| 25 | ); | ||
| 26 | |||
| 27 | public static readonly TableDefinition SqlFileSpec = new TableDefinition( | ||
| 28 | "SqlFileSpec", | ||
| 29 | new[] | ||
| 30 | { | ||
| 31 | new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), | ||
| 32 | new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Logical name of filespec", modularizeType: ColumnModularizeType.Property), | ||
| 33 | new ColumnDefinition("Filename", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Filename to use (path must exist)", modularizeType: ColumnModularizeType.Property), | ||
| 34 | new ColumnDefinition("Size", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Initial size for file", modularizeType: ColumnModularizeType.Property), | ||
| 35 | new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), | ||
| 36 | new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), | ||
| 37 | }, | ||
| 38 | tupleDefinitionName: "SqlFileSpec", | ||
| 39 | tupleIdIsPrimaryKey: true | ||
| 40 | ); | ||
| 41 | |||
| 42 | public static readonly TableDefinition SqlScript = new TableDefinition( | ||
| 43 | "SqlScript", | ||
| 44 | new[] | ||
| 45 | { | ||
| 46 | new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), | ||
| 47 | new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), | ||
| 48 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), | ||
| 49 | new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), | ||
| 50 | new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), | ||
| 51 | new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), | ||
| 52 | new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), | ||
| 53 | }, | ||
| 54 | tupleDefinitionName: "SqlScript", | ||
| 55 | tupleIdIsPrimaryKey: true | ||
| 56 | ); | ||
| 57 | |||
| 58 | public static readonly TableDefinition SqlString = new TableDefinition( | ||
| 59 | "SqlString", | ||
| 60 | new[] | ||
| 61 | { | ||
| 62 | new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), | ||
| 63 | new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), | ||
| 64 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), | ||
| 65 | new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), | ||
| 66 | new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), | ||
| 67 | new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), | ||
| 68 | new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), | ||
| 69 | }, | ||
| 70 | tupleDefinitionName: "SqlString", | ||
| 71 | tupleIdIsPrimaryKey: true | ||
| 72 | ); | ||
| 73 | |||
| 74 | public static readonly TableDefinition[] All = new[] | ||
| 75 | { | ||
| 76 | SqlDatabase, | ||
| 77 | SqlFileSpec, | ||
| 78 | SqlScript, | ||
| 79 | SqlString, | ||
| 80 | }; | ||
| 81 | } | ||
| 82 | } | ||
diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs index 83505059..b679e871 100644 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs | |||
| @@ -1,32 +1,13 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | 2 | ||
| 3 | namespace WixToolset.Sql | 3 | namespace WixToolset.Sql |
| 4 | { | 4 | { |
| 5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 6 | using System.Linq; | ||
| 7 | using System.Xml; | ||
| 8 | using WixToolset.Data.WindowsInstaller; | 6 | using WixToolset.Data.WindowsInstaller; |
| 9 | using WixToolset.Extensibility; | 7 | using WixToolset.Extensibility; |
| 10 | 8 | ||
| 11 | public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension | 9 | public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension |
| 12 | { | 10 | { |
| 13 | public SqlWindowsInstallerBackendBinderExtension() | 11 | public override IEnumerable<TableDefinition> TableDefinitions => SqlTableDefinitions.All; |
| 14 | { | ||
| 15 | |||
| 16 | } | ||
| 17 | |||
| 18 | private static readonly TableDefinition[] Tables = LoadTables(); | ||
| 19 | |||
| 20 | public override IEnumerable<TableDefinition> TableDefinitions => Tables; | ||
| 21 | |||
| 22 | private static TableDefinition[] LoadTables() | ||
| 23 | { | ||
| 24 | using (var resourceStream = typeof(SqlWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Sql.tables.xml")) | ||
| 25 | using (var reader = XmlReader.Create(resourceStream)) | ||
| 26 | { | ||
| 27 | var tables = TableDefinitionCollection.Load(reader); | ||
| 28 | return tables.ToArray(); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | 12 | } |
| 32 | } | 13 | } |
diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs index fd107690..1e056212 100644 --- a/src/wixext/Tuples/SqlDatabaseTuple.cs +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs | |||
| @@ -11,14 +11,13 @@ namespace WixToolset.Sql | |||
| 11 | SqlTupleDefinitionType.SqlDatabase.ToString(), | 11 | SqlTupleDefinitionType.SqlDatabase.ToString(), |
| 12 | new[] | 12 | new[] |
| 13 | { | 13 | { |
| 14 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.SqlDb), IntermediateFieldType.String), | ||
| 15 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), | 14 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), | 15 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), |
| 17 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), |
| 18 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Component_), IntermediateFieldType.String), | 17 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.ComponentRef), IntermediateFieldType.String), |
| 19 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.User_), IntermediateFieldType.String), | 18 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.UserRef), IntermediateFieldType.String), |
| 20 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_), IntermediateFieldType.String), | 19 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpecRef), IntermediateFieldType.String), |
| 21 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_Log), IntermediateFieldType.String), | 20 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.LogFileSpecRef), IntermediateFieldType.String), |
| 22 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), | 21 | new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), |
| 23 | }, | 22 | }, |
| 24 | typeof(SqlDatabaseTuple)); | 23 | typeof(SqlDatabaseTuple)); |
| @@ -31,14 +30,13 @@ namespace WixToolset.Sql.Tuples | |||
| 31 | 30 | ||
| 32 | public enum SqlDatabaseTupleFields | 31 | public enum SqlDatabaseTupleFields |
| 33 | { | 32 | { |
| 34 | SqlDb, | ||
| 35 | Server, | 33 | Server, |
| 36 | Instance, | 34 | Instance, |
| 37 | Database, | 35 | Database, |
| 38 | Component_, | 36 | ComponentRef, |
| 39 | User_, | 37 | UserRef, |
| 40 | FileSpec_, | 38 | FileSpecRef, |
| 41 | FileSpec_Log, | 39 | LogFileSpecRef, |
| 42 | Attributes, | 40 | Attributes, |
| 43 | } | 41 | } |
| 44 | 42 | ||
| @@ -54,12 +52,6 @@ namespace WixToolset.Sql.Tuples | |||
| 54 | 52 | ||
| 55 | public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; | 53 | public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; |
| 56 | 54 | ||
| 57 | public string SqlDb | ||
| 58 | { | ||
| 59 | get => this.Fields[(int)SqlDatabaseTupleFields.SqlDb].AsString(); | ||
| 60 | set => this.Set((int)SqlDatabaseTupleFields.SqlDb, value); | ||
| 61 | } | ||
| 62 | |||
| 63 | public string Server | 55 | public string Server |
| 64 | { | 56 | { |
| 65 | get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); | 57 | get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); |
| @@ -78,28 +70,28 @@ namespace WixToolset.Sql.Tuples | |||
| 78 | set => this.Set((int)SqlDatabaseTupleFields.Database, value); | 70 | set => this.Set((int)SqlDatabaseTupleFields.Database, value); |
| 79 | } | 71 | } |
| 80 | 72 | ||
| 81 | public string Component_ | 73 | public string ComponentRef |
| 82 | { | 74 | { |
| 83 | get => this.Fields[(int)SqlDatabaseTupleFields.Component_].AsString(); | 75 | get => this.Fields[(int)SqlDatabaseTupleFields.ComponentRef].AsString(); |
| 84 | set => this.Set((int)SqlDatabaseTupleFields.Component_, value); | 76 | set => this.Set((int)SqlDatabaseTupleFields.ComponentRef, value); |
| 85 | } | 77 | } |
| 86 | 78 | ||
| 87 | public string User_ | 79 | public string UserRef |
| 88 | { | 80 | { |
| 89 | get => this.Fields[(int)SqlDatabaseTupleFields.User_].AsString(); | 81 | get => this.Fields[(int)SqlDatabaseTupleFields.UserRef].AsString(); |
| 90 | set => this.Set((int)SqlDatabaseTupleFields.User_, value); | 82 | set => this.Set((int)SqlDatabaseTupleFields.UserRef, value); |
| 91 | } | 83 | } |
| 92 | 84 | ||
| 93 | public string FileSpec_ | 85 | public string FileSpecRef |
| 94 | { | 86 | { |
| 95 | get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_].AsString(); | 87 | get => this.Fields[(int)SqlDatabaseTupleFields.FileSpecRef].AsString(); |
| 96 | set => this.Set((int)SqlDatabaseTupleFields.FileSpec_, value); | 88 | set => this.Set((int)SqlDatabaseTupleFields.FileSpecRef, value); |
| 97 | } | 89 | } |
| 98 | 90 | ||
| 99 | public string FileSpec_Log | 91 | public string LogFileSpecRef |
| 100 | { | 92 | { |
| 101 | get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_Log].AsString(); | 93 | get => this.Fields[(int)SqlDatabaseTupleFields.LogFileSpecRef].AsString(); |
| 102 | set => this.Set((int)SqlDatabaseTupleFields.FileSpec_Log, value); | 94 | set => this.Set((int)SqlDatabaseTupleFields.LogFileSpecRef, value); |
| 103 | } | 95 | } |
| 104 | 96 | ||
| 105 | public int Attributes | 97 | public int Attributes |
diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs index 9813ec83..98a3002b 100644 --- a/src/wixext/Tuples/SqlFileSpecTuple.cs +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs | |||
| @@ -11,7 +11,6 @@ namespace WixToolset.Sql | |||
| 11 | SqlTupleDefinitionType.SqlFileSpec.ToString(), | 11 | SqlTupleDefinitionType.SqlFileSpec.ToString(), |
| 12 | new[] | 12 | new[] |
| 13 | { | 13 | { |
| 14 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.FileSpec), IntermediateFieldType.String), | ||
| 15 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), | 14 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), | 15 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), |
| 17 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), |
| @@ -28,7 +27,6 @@ namespace WixToolset.Sql.Tuples | |||
| 28 | 27 | ||
| 29 | public enum SqlFileSpecTupleFields | 28 | public enum SqlFileSpecTupleFields |
| 30 | { | 29 | { |
| 31 | FileSpec, | ||
| 32 | Name, | 30 | Name, |
| 33 | Filename, | 31 | Filename, |
| 34 | Size, | 32 | Size, |
| @@ -48,12 +46,6 @@ namespace WixToolset.Sql.Tuples | |||
| 48 | 46 | ||
| 49 | public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; | 47 | public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; |
| 50 | 48 | ||
| 51 | public string FileSpec | ||
| 52 | { | ||
| 53 | get => this.Fields[(int)SqlFileSpecTupleFields.FileSpec].AsString(); | ||
| 54 | set => this.Set((int)SqlFileSpecTupleFields.FileSpec, value); | ||
| 55 | } | ||
| 56 | |||
| 57 | public string Name | 49 | public string Name |
| 58 | { | 50 | { |
| 59 | get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); | 51 | get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); |
diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs index b1f95709..de76d49d 100644 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ b/src/wixext/Tuples/SqlScriptTuple.cs | |||
| @@ -11,11 +11,10 @@ namespace WixToolset.Sql | |||
| 11 | SqlTupleDefinitionType.SqlScript.ToString(), | 11 | SqlTupleDefinitionType.SqlScript.ToString(), |
| 12 | new[] | 12 | new[] |
| 13 | { | 13 | { |
| 14 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Script), IntermediateFieldType.String), | 14 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDbRef), IntermediateFieldType.String), |
| 15 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDb_), IntermediateFieldType.String), | 15 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ComponentRef), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Component_), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinaryRef), IntermediateFieldType.String), |
| 17 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinary_), IntermediateFieldType.String), | 17 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.UserRef), IntermediateFieldType.String), |
| 18 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.User_), IntermediateFieldType.String), | ||
| 19 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), | 18 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), |
| 20 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), | 19 | new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), |
| 21 | }, | 20 | }, |
| @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples | |||
| 29 | 28 | ||
| 30 | public enum SqlScriptTupleFields | 29 | public enum SqlScriptTupleFields |
| 31 | { | 30 | { |
| 32 | Script, | 31 | SqlDbRef, |
| 33 | SqlDb_, | 32 | ComponentRef, |
| 34 | Component_, | 33 | ScriptBinaryRef, |
| 35 | ScriptBinary_, | 34 | UserRef, |
| 36 | User_, | ||
| 37 | Attributes, | 35 | Attributes, |
| 38 | Sequence, | 36 | Sequence, |
| 39 | } | 37 | } |
| @@ -50,34 +48,28 @@ namespace WixToolset.Sql.Tuples | |||
| 50 | 48 | ||
| 51 | public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; | 49 | public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; |
| 52 | 50 | ||
| 53 | public string Script | 51 | public string SqlDbRef |
| 54 | { | 52 | { |
| 55 | get => this.Fields[(int)SqlScriptTupleFields.Script].AsString(); | 53 | get => this.Fields[(int)SqlScriptTupleFields.SqlDbRef].AsString(); |
| 56 | set => this.Set((int)SqlScriptTupleFields.Script, value); | 54 | set => this.Set((int)SqlScriptTupleFields.SqlDbRef, value); |
| 57 | } | 55 | } |
| 58 | 56 | ||
| 59 | public string SqlDb_ | 57 | public string ComponentRef |
| 60 | { | 58 | { |
| 61 | get => this.Fields[(int)SqlScriptTupleFields.SqlDb_].AsString(); | 59 | get => this.Fields[(int)SqlScriptTupleFields.ComponentRef].AsString(); |
| 62 | set => this.Set((int)SqlScriptTupleFields.SqlDb_, value); | 60 | set => this.Set((int)SqlScriptTupleFields.ComponentRef, value); |
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | public string Component_ | 63 | public string ScriptBinaryRef |
| 66 | { | 64 | { |
| 67 | get => this.Fields[(int)SqlScriptTupleFields.Component_].AsString(); | 65 | get => this.Fields[(int)SqlScriptTupleFields.ScriptBinaryRef].AsString(); |
| 68 | set => this.Set((int)SqlScriptTupleFields.Component_, value); | 66 | set => this.Set((int)SqlScriptTupleFields.ScriptBinaryRef, value); |
| 69 | } | 67 | } |
| 70 | 68 | ||
| 71 | public string ScriptBinary_ | 69 | public string UserRef |
| 72 | { | 70 | { |
| 73 | get => this.Fields[(int)SqlScriptTupleFields.ScriptBinary_].AsString(); | 71 | get => this.Fields[(int)SqlScriptTupleFields.UserRef].AsString(); |
| 74 | set => this.Set((int)SqlScriptTupleFields.ScriptBinary_, value); | 72 | set => this.Set((int)SqlScriptTupleFields.UserRef, value); |
| 75 | } | ||
| 76 | |||
| 77 | public string User_ | ||
| 78 | { | ||
| 79 | get => this.Fields[(int)SqlScriptTupleFields.User_].AsString(); | ||
| 80 | set => this.Set((int)SqlScriptTupleFields.User_, value); | ||
| 81 | } | 73 | } |
| 82 | 74 | ||
| 83 | public int Attributes | 75 | public int Attributes |
diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs index d2cba0e0..77882d33 100644 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ b/src/wixext/Tuples/SqlStringTuple.cs | |||
| @@ -11,11 +11,10 @@ namespace WixToolset.Sql | |||
| 11 | SqlTupleDefinitionType.SqlString.ToString(), | 11 | SqlTupleDefinitionType.SqlString.ToString(), |
| 12 | new[] | 12 | new[] |
| 13 | { | 13 | { |
| 14 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.String), IntermediateFieldType.String), | 14 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDbRef), IntermediateFieldType.String), |
| 15 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDb_), IntermediateFieldType.String), | 15 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.ComponentRef), IntermediateFieldType.String), |
| 16 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Component_), IntermediateFieldType.String), | ||
| 17 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), |
| 18 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.User_), IntermediateFieldType.String), | 17 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.UserRef), IntermediateFieldType.String), |
| 19 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), | 18 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), |
| 20 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), | 19 | new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), |
| 21 | }, | 20 | }, |
| @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples | |||
| 29 | 28 | ||
| 30 | public enum SqlStringTupleFields | 29 | public enum SqlStringTupleFields |
| 31 | { | 30 | { |
| 32 | String, | 31 | SqlDbRef, |
| 33 | SqlDb_, | 32 | ComponentRef, |
| 34 | Component_, | ||
| 35 | SQL, | 33 | SQL, |
| 36 | User_, | 34 | UserRef, |
| 37 | Attributes, | 35 | Attributes, |
| 38 | Sequence, | 36 | Sequence, |
| 39 | } | 37 | } |
| @@ -50,22 +48,16 @@ namespace WixToolset.Sql.Tuples | |||
| 50 | 48 | ||
| 51 | public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; | 49 | public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; |
| 52 | 50 | ||
| 53 | public string String | 51 | public string SqlDbRef |
| 54 | { | 52 | { |
| 55 | get => this.Fields[(int)SqlStringTupleFields.String].AsString(); | 53 | get => this.Fields[(int)SqlStringTupleFields.SqlDbRef].AsString(); |
| 56 | set => this.Set((int)SqlStringTupleFields.String, value); | 54 | set => this.Set((int)SqlStringTupleFields.SqlDbRef, value); |
| 57 | } | 55 | } |
| 58 | 56 | ||
| 59 | public string SqlDb_ | 57 | public string ComponentRef |
| 60 | { | 58 | { |
| 61 | get => this.Fields[(int)SqlStringTupleFields.SqlDb_].AsString(); | 59 | get => this.Fields[(int)SqlStringTupleFields.ComponentRef].AsString(); |
| 62 | set => this.Set((int)SqlStringTupleFields.SqlDb_, value); | 60 | set => this.Set((int)SqlStringTupleFields.ComponentRef, value); |
| 63 | } | ||
| 64 | |||
| 65 | public string Component_ | ||
| 66 | { | ||
| 67 | get => this.Fields[(int)SqlStringTupleFields.Component_].AsString(); | ||
| 68 | set => this.Set((int)SqlStringTupleFields.Component_, value); | ||
| 69 | } | 61 | } |
| 70 | 62 | ||
| 71 | public string SQL | 63 | public string SQL |
| @@ -74,10 +66,10 @@ namespace WixToolset.Sql.Tuples | |||
| 74 | set => this.Set((int)SqlStringTupleFields.SQL, value); | 66 | set => this.Set((int)SqlStringTupleFields.SQL, value); |
| 75 | } | 67 | } |
| 76 | 68 | ||
| 77 | public string User_ | 69 | public string UserRef |
| 78 | { | 70 | { |
| 79 | get => this.Fields[(int)SqlStringTupleFields.User_].AsString(); | 71 | get => this.Fields[(int)SqlStringTupleFields.UserRef].AsString(); |
| 80 | set => this.Set((int)SqlStringTupleFields.User_, value); | 72 | set => this.Set((int)SqlStringTupleFields.UserRef, value); |
| 81 | } | 73 | } |
| 82 | 74 | ||
| 83 | public int Attributes | 75 | public int Attributes |
diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index 5db8b9d3..73c7a4e5 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | <ItemGroup> | 14 | <ItemGroup> |
| 15 | <Content Include="$(MSBuildThisFileName).targets" /> | 15 | <Content Include="$(MSBuildThisFileName).targets" /> |
| 16 | <Content Include="sql.xsd" PackagePath="tools" /> | 16 | <Content Include="sql.xsd" PackagePath="tools" /> |
| 17 | <EmbeddedResource Include="tables.xml" /> | ||
| 18 | <EmbeddedResource Include="$(OutputPath)..\sql.wixlib" /> | 17 | <EmbeddedResource Include="$(OutputPath)..\sql.wixlib" /> |
| 19 | </ItemGroup> | 18 | </ItemGroup> |
| 20 | 19 | ||
diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index a8b6c3a1..00000000 --- a/src/wixext/tables.xml +++ /dev/null | |||
| @@ -1,73 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8" ?> | ||
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 3 | |||
| 4 | |||
| 5 | <tableDefinitions xmlns="http://wixtoolset.org/schemas/v4/wi/tables"> | ||
| 6 | <tableDefinition name="SqlDatabase" createSymbols="yes"> | ||
| 7 | <columnDefinition name="SqlDb" type="string" length="72" primaryKey="yes" modularize="column" | ||
| 8 | category="identifier" description="Primary key, non-localized token"/> | ||
| 9 | <columnDefinition name="Server" type="string" length="255" nullable="yes" | ||
| 10 | category="formatted" description="Primary key, name of server running SQL Server"/> | ||
| 11 | <columnDefinition name="Instance" type="string" length="255" nullable="yes" | ||
| 12 | category="formatted" description="Primary key, name of SQL Server instance"/> | ||
| 13 | <!-- TODO: change the Database column length to "128" in WiX v4.0 when we can put in breaking changes --> | ||
| 14 | <columnDefinition name="Database" type="string" length="255" | ||
| 15 | category="formatted" description="Primary key, name of database in a SQL Server"/> | ||
| 16 | <columnDefinition name="Component_" type="string" length="72" modularize="column" nullable="yes" | ||
| 17 | keyTable="Component" keyColumn="1" category="identifier" description="Foreign key, Component used to determine install state "/> | ||
| 18 | <columnDefinition name="User_" type="string" length="72" nullable="yes" modularize="column" | ||
| 19 | keyTable="User" keyColumn="1" category="identifier" description="Foreign key, User used to log into database"/> | ||
| 20 | <columnDefinition name="FileSpec_" type="string" length="72" nullable="yes" modularize="column" | ||
| 21 | keyTable="SqlFileSpec" keyColumn="1" category="identifier" description="Foreign key referencing SqlFileSpec."/> | ||
| 22 | <columnDefinition name="FileSpec_Log" type="string" length="72" nullable="yes" modularize="column" | ||
| 23 | keyTable="SqlFileSpec" keyColumn="1" category="identifier" description="Foreign key referencing SqlFileSpec."/> | ||
| 24 | <columnDefinition name="Attributes" type="number" length="2" nullable="yes" | ||
| 25 | minValue="0" maxValue="255" description="1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall" /> | ||
| 26 | </tableDefinition> | ||
| 27 | <tableDefinition name="SqlFileSpec" createSymbols="yes"> | ||
| 28 | <columnDefinition name="FileSpec" type="string" length="72" primaryKey="yes" modularize="column" | ||
| 29 | category="identifier" description="Primary key, non-localized token"/> | ||
| 30 | <columnDefinition name="Name" type="string" length="255" modularize="property" | ||
| 31 | category="formatted" description="Logical name of filespec"/> | ||
| 32 | <columnDefinition name="Filename" type="string" length="255" modularize="property" | ||
| 33 | category="formatted" description="Filename to use (path must exist)"/> | ||
| 34 | <columnDefinition name="Size" type="string" length="72" nullable="yes" modularize="property" | ||
| 35 | category="formatted" description="Initial size for file"/> | ||
| 36 | <columnDefinition name="MaxSize" type="string" length="72" nullable="yes" modularize="property" | ||
| 37 | category="formatted" description="Maximum size for file"/> | ||
| 38 | <columnDefinition name="GrowthSize" type="string" length="72" nullable="yes" modularize="property" | ||
| 39 | category="formatted" description="Size file should grow when necessary"/> | ||
| 40 | </tableDefinition> | ||
| 41 | <tableDefinition name="SqlScript"> | ||
| 42 | <columnDefinition name="Script" type="string" length="72" primaryKey="yes" | ||
| 43 | category="identifier" description="Primary key, non-localized token"/> | ||
| 44 | <columnDefinition name="SqlDb_" type="string" length="72" modularize="column" | ||
| 45 | keyTable="SqlDatabase" keyColumn="1" category="identifier" description="Foreign key, SQL Server key"/> | ||
| 46 | <columnDefinition name="Component_" type="string" length="72" modularize="column" | ||
| 47 | keyTable="Component" keyColumn="1" category="identifier" description="Foreign key, Component used to determine install state"/> | ||
| 48 | <columnDefinition name="ScriptBinary_" type="string" length="72" modularize="column" | ||
| 49 | keyTable="Binary" keyColumn="1" category="identifier" description="Foreign key, Binary stream that contains SQL Script to execute"/> | ||
| 50 | <columnDefinition name="User_" type="string" length="72" nullable="yes" modularize="column" | ||
| 51 | keyTable="User" keyColumn="1" category="identifier" description="Foreign key, User used to log into database"/> | ||
| 52 | <columnDefinition name="Attributes" type="number" length="2" | ||
| 53 | set="1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31" description="1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"/> | ||
| 54 | <columnDefinition name="Sequence" type="number" length="2" nullable="yes" | ||
| 55 | description="Order to execute SQL Queries in"/> | ||
| 56 | </tableDefinition> | ||
| 57 | <tableDefinition name="SqlString"> | ||
| 58 | <columnDefinition name="String" type="string" length="72" modularize="column" primaryKey="yes" | ||
| 59 | category="identifier" description="Id for the SqlString" /> | ||
| 60 | <columnDefinition name="SqlDb_" type="string" length="72" modularize="column" | ||
| 61 | keyTable="SqlDatabase" keyColumn="1" category="identifier" description="Foreign key, SQL Server key"/> | ||
| 62 | <columnDefinition name="Component_" type="string" length="72" modularize="column" | ||
| 63 | keyTable="Component" keyColumn="1" category="identifier" description="Foreign key, Component used to determine install state"/> | ||
| 64 | <columnDefinition name="SQL" type="string" length="0" | ||
| 65 | category="formatted" description="SQL query to execute" escapeIdtCharacters="yes"/> | ||
| 66 | <columnDefinition name="User_" type="string" length="72" nullable="yes" modularize="column" | ||
| 67 | keyTable="User" keyColumn="1" category="identifier" description="Foreign key, User used to log into database"/> | ||
| 68 | <columnDefinition name="Attributes" type="number" length="2" | ||
| 69 | set="1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31" description="1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"/> | ||
| 70 | <columnDefinition name="Sequence" type="number" length="2" nullable="yes" | ||
| 71 | description="Order to execute SQL Queries in"/> | ||
| 72 | </tableDefinition> | ||
| 73 | </tableDefinitions> | ||
