mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
Proposed fix for : 3653 : Cancel not working even after disconnecting (#797)
* Proposed changes to stop query execution if an exception has occured before/during batch execution * Sending the error message was causing a test to fail - so removing for now. We can update the test to expect this is needed.
This commit is contained in:
@@ -226,7 +226,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!HasExecuted && !HasCancelled)
|
||||
if (!HasExecuted && !HasCancelled && !HasErrored)
|
||||
{
|
||||
throw new InvalidOperationException("Query has not been executed.");
|
||||
}
|
||||
@@ -264,6 +264,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
/// </summary>
|
||||
public bool HasCancelled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// if the query has errored out (before batch execution started)
|
||||
/// </summary>
|
||||
public bool HasErrored { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text of the query to execute
|
||||
/// </summary>
|
||||
@@ -393,7 +398,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Locate and setup the connection
|
||||
DbConnection queryConnection = await ConnectionService.Instance.GetOrOpenConnection(editorConnection.OwnerUri, ConnectionType.Query);
|
||||
sqlConn = queryConnection as ReliableSqlConnection;
|
||||
@@ -438,6 +443,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
HasErrored = true;
|
||||
if (e is OperationCanceledException)
|
||||
{
|
||||
await BatchMessageSent(new ResultMessage(SR.QueryServiceQueryCancelled, false, null));
|
||||
|
||||
Reference in New Issue
Block a user