From c596a0db7ac125b41303bc63a12419951bbb0695 Mon Sep 17 00:00:00 2001 From: Benjamin Russell Date: Thu, 11 Aug 2016 17:41:18 -0700 Subject: [PATCH] Small tweaks to query execution * Adding comments where missing * Adding "# rows affected" only if there was 0 or more --- .../QueryExecution/Query.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs index 292b1e81..887bbbaf 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Query.cs @@ -34,6 +34,9 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution /// public ConnectionInfo EditorConnection { get; set; } + /// + /// Whether or not the query has an error + /// public bool HasError { get; set; } /// @@ -120,7 +123,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution using (conn = EditorConnection.Factory.CreateSqlConnection(connectionString)) { // If we have the message listener, bind to it - // TODO: This doesn't allow testing via mocking SqlConnection sqlConn = conn as SqlConnection; if (sqlConn != null) { @@ -141,7 +143,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution do { // Create a message with the number of affected rows - ResultMessages.Add(String.Format("({0} row(s) affected)", reader.RecordsAffected)); + if (reader.RecordsAffected >= 0) + { + ResultMessages.Add(String.Format("({0} row(s) affected)", reader.RecordsAffected)); + } if (!reader.HasRows && reader.FieldCount == 0) {