Fix Ops Studio issue 97 where query connection is dropped (#549)

- Fixes https://github.com/Microsoft/sqlopsstudio/issues/97.
- This should fix the bulk of the issues reported by users since it's the 1st use of this connection in the query code path.
- Implemented the fix in the connection service. This will always open a connection when calling `GetOrOpenConnection`. I cannot see a reason why the connection returned from this should ever be closed.
- resolve issues in both this code path and the edit data code path since both use this method.
This commit is contained in:
Kevin Cunnane
2017-11-21 14:46:20 -08:00
committed by GitHub
parent c512d53caa
commit 42ee96f99f
5 changed files with 105 additions and 39 deletions

View File

@@ -1250,7 +1250,13 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Connection
connInfo = service.OwnerToConnectionMap[connectionParameters.OwnerUri];
Assert.NotNull(defaultConn);
Assert.Equal(connInfo.AllConnections.Count, 1);
// Verify that if the query connection was closed, it will be reopened on requesting the connection again
Assert.Equal(ConnectionState.Open, queryConn.State);
queryConn.Close();
Assert.Equal(ConnectionState.Closed, queryConn.State);
queryConn = await service.GetOrOpenConnection(connectionParameters.OwnerUri, ConnectionType.Query);
Assert.Equal(ConnectionState.Open, queryConn.State);
}
[Fact]

View File

@@ -216,6 +216,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
public override void Close()
{
// No Op
this._state = ConnectionState.Closed;
}
public override void Open()
@@ -225,6 +226,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{
throw new Exception("Invalid credentials provided");
}
this._state = ConnectionState.Open;
}
public override string ConnectionString { get; set; }