mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 17:24:00 -05:00
Support "SQL" settings in addition to MSSQL (#398)
* Support "SQL" settings in addition to MSSQL - Handles having 2 separate configuration definitions and merging / treating them as 1 throughout the app - If a settings group such as Intellisense is defined on mssql, it will override any generic SQL properties - Retains backwards compatibility with existing settings.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Globalization;
|
||||
using Microsoft.SqlTools.ServiceLayer.Formatter;
|
||||
using Microsoft.SqlTools.ServiceLayer.Formatter.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
@@ -28,10 +29,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
|
||||
[Fact]
|
||||
public void ValidateFormatSettingsParsedFromJson()
|
||||
{
|
||||
const string settingsJson = @"
|
||||
ValidateFormatSettings("mssql");
|
||||
ValidateFormatSettings("sql");
|
||||
}
|
||||
|
||||
private static void ValidateFormatSettings(string settingsPropertyName)
|
||||
{
|
||||
string settingsJson = @"
|
||||
{
|
||||
""params"": {
|
||||
""mssql"": {
|
||||
""" + settingsPropertyName + @""": {
|
||||
""format"": {
|
||||
useBracketForIdentifiers: true,
|
||||
placeCommasBeforeNextStatement: true,
|
||||
@@ -46,9 +53,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
|
||||
|
||||
JObject message = JObject.Parse(settingsJson);
|
||||
JToken messageParams = null;
|
||||
message.TryGetValue("params", out messageParams);
|
||||
message.TryGetValue("params", out messageParams);
|
||||
SqlToolsSettings sqlToolsSettings = messageParams.ToObject<SqlToolsSettings>();
|
||||
|
||||
|
||||
Assert.True(sqlToolsSettings.SqlTools.Format.AlignColumnDefinitionsInColumns);
|
||||
Assert.Equal(CasingOptions.Lowercase, sqlToolsSettings.SqlTools.Format.DatatypeCasing);
|
||||
Assert.Equal(CasingOptions.Uppercase, sqlToolsSettings.SqlTools.Format.KeywordCasing);
|
||||
@@ -56,7 +63,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Formatter
|
||||
Assert.True(sqlToolsSettings.SqlTools.Format.PlaceSelectStatementReferencesOnNewLine);
|
||||
Assert.True(sqlToolsSettings.SqlTools.Format.UseBracketForIdentifiers);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void FormatOptionsMatchDefaultSettings()
|
||||
{
|
||||
|
||||
@@ -31,11 +31,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution
|
||||
|
||||
[Fact]
|
||||
public void ValidateSettingsParsedFromJson()
|
||||
{
|
||||
ValidateSettings("mssql");
|
||||
ValidateSettings("sql");
|
||||
}
|
||||
|
||||
private static void ValidateSettings(string settingsPropertyName)
|
||||
{
|
||||
// NOTE: Only testing displayBitAsNumber for now because it is the only one piped through
|
||||
const string settingsJson = @"{"
|
||||
string settingsJson = @"{"
|
||||
+ @"""params"": {"
|
||||
+ @"""mssql"": {"
|
||||
+ @""""+settingsPropertyName+@""": {"
|
||||
+ @"""query"": {"
|
||||
+ @"displayBitAsNumber: false"
|
||||
+ @"}"
|
||||
|
||||
Reference in New Issue
Block a user