Fix scripting data in the scripting service (#337)

A regression was introduced in the scripting service refactoring where data is no longer scripted. This commit fixes the issue, and updates the tests to catch this in the future.

The issue is in the getter for SqlScriptPublishModel.AdvancedOptions, there is some strange logic which will cause the SqlScriptPublishModel.AdvancedOptions to get reset and lose all values based the ordering of when SqlScriptPublishModel.ScriptAllObjects is set.  In the scripting service refactoring, we started to hit this reset of the AdvanceOptions, which would lose the option to script data, along with other options.

To workaround this, we initialize with SqlScriptPublishModel.ScriptAllObjects to true, and then set all SqlScriptPublishModel.AdvancedOptions values.  Then, we set SqlScriptPublishModel.ScriptAllObjects, and avoid calling the SqlScriptPublishModel.AdvancedOptions getter.

Also including some misc scripting service changes:
1) Adding a sequence number field to the scripting operation events
2) Adding a error message to scripting progress events
3) Expect a null scripting option parameter
4) Correctly set the exception message and details for json-rpc events
5) More logging
This commit is contained in:
Brian O'Neill
2017-05-10 12:06:59 -07:00
committed by GitHub
parent 39f5279631
commit 8a54435a9c
8 changed files with 172 additions and 41 deletions

View File

@@ -12,14 +12,29 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
/// </summary>
public class ScriptingCompleteParams : ScriptingEventParams
{
/// <summary>
/// Get or sets the error details for an error that occurred during the scripting operation.
/// </summary>
public string ErrorDetails { get; set; }
/// <summary>
/// Get or sets the error message for an error that occurred during the scripting operation.
/// </summary>
public string ErrorMessage { get; set; }
/// <summary>
/// Get or sets a value to indicate an error occurred during the scripting operation.
/// </summary>
public bool HasError { get; set; }
/// <summary>
/// Get or sets a value to indicate the scripting operation was canceled.
/// </summary>
public bool Canceled { get; set; }
/// <summary>
/// Get or sets a value to indicate the scripting operation successfully completed.
/// </summary>
public bool Success { get; set; }
}

View File

@@ -14,5 +14,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
/// Gets or sets the operation id of the scripting operation this event is associated with.
/// </summary>
public string OperationId { get; set; }
/// <summary>
/// Gets or sets the sequence number. The sequence number starts at 1, and is incremented each time a scripting event is
/// raised for the current scripting operation.
/// </summary>
public int SequenceNumber { get; set; }
}
}

View File

@@ -16,7 +16,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
/// <summary>
/// Gets or sets the list of database objects returned from the list objects operation.
/// </summary>
public List<ScriptingObject> DatabaseObjects { get; set; }
public List<ScriptingObject> ScriptingObjects { get; set; }
/// <summary>
/// Gets or sets the count of database object returned from the list objects operation.

View File

@@ -39,6 +39,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting.Contracts
/// Gets or sets the error details if an error occurred scripting a database object.
/// </summary>
public string ErrorDetails { get; set; }
/// <summary>
/// Get or sets the error message for an error that occurred scripting a database object.
/// </summary>
public string ErrorMessage { get; set; }
}
/// <summary>