Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving out legacy schemas into their own folder #1866

Merged
merged 9 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,14 @@ public static string SchemaHierarchy_Schemas
}
}

public static string SchemaHierarchy_LegacySchemas
{
get
{
return Keys.GetString(Keys.SchemaHierarchy_LegacySchemas);
}
}

public static string SchemaHierarchy_Security
{
get
Expand Down Expand Up @@ -10674,6 +10682,9 @@ public class Keys
public const string SchemaHierarchy_Schemas = "SchemaHierarchy_Schemas";


public const string SchemaHierarchy_LegacySchemas = "SchemaHierarchy_LegacySchemas";


public const string SchemaHierarchy_Security = "SchemaHierarchy_Security";


Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@
<value>Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_LegacySchemas" xml:space="preserve">
<value>Legacy Schemas</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_Security" xml:space="preserve">
<value>Security</value>
<comment></comment>
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ SchemaHierarchy_Rules = Rules

SchemaHierarchy_Schemas = Schemas

SchemaHierarchy_LegacySchemas = Legacy Schemas

SchemaHierarchy_Security = Security

SchemaHierarchy_ServerObjects = Server Objects
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6545,6 +6545,11 @@ The Query Processor estimates that implementing the following index could improv
<target state="new">Sequence Number End</target>
<note></note>
</trans-unit>
<trans-unit id="SchemaHierarchy_LegacySchemas">
<source>Legacy Schemas</source>
<target state="new">Legacy Schemas</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public class NodePropertyFilter : INodeFilter
/// </summary>
public Type TypeToReverse { get; set; } = default!;

/// <summary>
/// Indicates if the filter is a "not" filter. Eg (not(@IsSystemObject = 0))
/// </summary>
public bool IsNotFilter { get; set; } = false;

/// <summary>
/// Indicates the type of the filter. It can be EQUALS, DATETIME, FALSE or CONTAINS
/// More information can be found here:
/// https://learn.microsoft.com/en-us/sql/powershell/query-expressions-and-uniform-resource-names?view=sql-server-ver16#examples
/// </summary>
public FilterType FilterType { get; set; } = FilterType.EQUALS;

/// <summary>
/// Returns true if the filter can be apply to the given type and Server type
/// </summary>
Expand Down Expand Up @@ -82,8 +94,35 @@ public string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
propertyValue = (int)Convert.ChangeType(value, Type);
}

string filterText = string.Empty;
switch (FilterType)
{
case FilterType.EQUALS:
filterText = $"@{Property} = {propertyValue}";
break;
case FilterType.DATETIME:
filterText = $"@{Property} = datetime({propertyValue})";
break;
case FilterType.CONTAINS:
filterText = $"contains(@{Property}, {propertyValue})";
break;
case FilterType.FALSE:
filterText = $"@{Property} = false()";
break;
case FilterType.ISNULL:
filterText = $"isnull(@{Property})";
break;
}

string orPrefix = filter.Length == 0 ? string.Empty : " or ";
filter.Append($"{orPrefix}@{Property} = {propertyValue}");
if (IsNotFilter)
{
filter.Append($"{orPrefix}not({filterText})");
}
else
{
filter.Append($"{orPrefix}{filterText}");
}
}

if (filter.Length != 0)
Expand All @@ -93,4 +132,14 @@ public string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
return string.Empty;
}
}

public enum FilterType
{
EQUALS,
DATETIME,
CONTAINS,
FALSE,
ISNULL

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
Expand Down Expand Up @@ -57,6 +57,7 @@ public enum NodeTypes
HistoryTable,
Indexes,
Keys,
LegacySchemas,
MasterKeys,
MessageTypes,
PartitionFunctions,
Expand Down
Loading