From f244d307e2ee1c0fe7a4dd53ab890c3d0fbe4dc1 Mon Sep 17 00:00:00 2001 From: Matt Irvine Date: Mon, 18 Jun 2018 17:39:25 -0700 Subject: [PATCH] Work around edit data trailing comment bug (#641) * Work around edit data trailing comment bug * Use Environment.NewLine --- src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs index e93e9553..f98d2bc4 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/Batch.cs @@ -358,6 +358,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution List columnSchemas = null; if (getFullColumnSchema) { + // Executing the same query twice with different command behavior causes the second + // execution to return no rows if there's a trailing comment with no newline after, + // so add a newline to the end of the query. See https://github.com/Microsoft/sqlopsstudio/issues/1424 + dbCommand.CommandText += Environment.NewLine; + // Fetch schema info separately, since CommandBehavior.KeyInfo will include primary // key columns in the result set, even if they weren't part of the select statement. // Extra key columns get added to the end, so just correlate via Column Ordinal.