mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Dropped Ledger Views folder (#1626)
* adding dropped ledger views to the OE hierarchy with ledger view naming and icons * updating tests
This commit is contained in:
@@ -2053,6 +2053,14 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string SchemaHierarchy_DroppedLedgerViews
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Keys.GetString(Keys.SchemaHierarchy_DroppedLedgerViews);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string SchemaHierarchy_AlwaysEncryptedKeys
|
public static string SchemaHierarchy_AlwaysEncryptedKeys
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -10656,6 +10664,9 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
public const string SchemaHierarchy_DroppedLedgerTables = "SchemaHierarchy_DroppedLedgerTables";
|
public const string SchemaHierarchy_DroppedLedgerTables = "SchemaHierarchy_DroppedLedgerTables";
|
||||||
|
|
||||||
|
|
||||||
|
public const string SchemaHierarchy_DroppedLedgerViews = "SchemaHierarchy_DroppedLedgerViews";
|
||||||
|
|
||||||
|
|
||||||
public const string SchemaHierarchy_AlwaysEncryptedKeys = "SchemaHierarchy_AlwaysEncryptedKeys";
|
public const string SchemaHierarchy_AlwaysEncryptedKeys = "SchemaHierarchy_AlwaysEncryptedKeys";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1284,6 +1284,10 @@
|
|||||||
<value>Dropped Ledger Tables</value>
|
<value>Dropped Ledger Tables</value>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SchemaHierarchy_DroppedLedgerViews" xml:space="preserve">
|
||||||
|
<value>Dropped Ledger Views</value>
|
||||||
|
<comment></comment>
|
||||||
|
</data>
|
||||||
<data name="SchemaHierarchy_AlwaysEncryptedKeys" xml:space="preserve">
|
<data name="SchemaHierarchy_AlwaysEncryptedKeys" xml:space="preserve">
|
||||||
<value>Always Encrypted Keys</value>
|
<value>Always Encrypted Keys</value>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
|
|||||||
@@ -632,6 +632,8 @@ SchemaHierarchy_ExternalTables = External Tables
|
|||||||
|
|
||||||
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
|
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
|
||||||
|
|
||||||
|
SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views
|
||||||
|
|
||||||
SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys
|
SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys
|
||||||
|
|
||||||
SchemaHierarchy_ColumnMasterKeys = Column Master Keys
|
SchemaHierarchy_ColumnMasterKeys = Column Master Keys
|
||||||
|
|||||||
@@ -6326,6 +6326,11 @@ The Query Processor estimates that implementing the following index could improv
|
|||||||
<target state="new">Dropped Ledger Tables</target>
|
<target state="new">Dropped Ledger Tables</target>
|
||||||
<note></note>
|
<note></note>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="SchemaHierarchy_DroppedLedgerViews">
|
||||||
|
<source>Dropped Ledger Views</source>
|
||||||
|
<target state="new">Dropped Ledger Views</target>
|
||||||
|
<note></note>
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
@@ -141,5 +141,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
ColumnMasterKeys,
|
ColumnMasterKeys,
|
||||||
ColumnEncryptionKeys,
|
ColumnEncryptionKeys,
|
||||||
DroppedLedgerTables,
|
DroppedLedgerTables,
|
||||||
|
DroppedLedgerViews,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,4 +136,47 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom name and icon for dropped ledger tables
|
||||||
|
/// </summary>
|
||||||
|
internal partial class DroppedLedgerTablesChildFactory : SmoChildFactoryBase
|
||||||
|
{
|
||||||
|
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Table? table = smoObject as Table;
|
||||||
|
if (table != null && IsPropertySupported("LedgerType", smoContext, table, CachedSmoProperties))
|
||||||
|
{
|
||||||
|
if (table.LedgerType == LedgerTableType.AppendOnlyLedgerTable)
|
||||||
|
{
|
||||||
|
return $"{table.Schema}.{table.Name} ({SR.AppendOnlyLedger_LabelPart})";
|
||||||
|
}
|
||||||
|
else if (table.LedgerType == LedgerTableType.UpdatableLedgerTable)
|
||||||
|
{
|
||||||
|
return $"{table.Schema}.{table.Name} ({SR.UpdatableLedger_LabelPart})";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Ignore the exception and just not change create custom name
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext)
|
||||||
|
{
|
||||||
|
return "Ledger";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetNodePathName(object smoObject)
|
||||||
|
{
|
||||||
|
return TableCustomNodeHelper.GetPathName(smoObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -895,6 +895,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
Type = typeof(bool),
|
Type = typeof(bool),
|
||||||
Values = new List<object> { 0 },
|
Values = new List<object> { 0 },
|
||||||
});
|
});
|
||||||
|
filters.Add(new NodePropertyFilter
|
||||||
|
{
|
||||||
|
Property = "IsDroppedLedgerView",
|
||||||
|
Type = typeof(bool),
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
|
Values = new List<object> { 0 },
|
||||||
|
});
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -909,6 +916,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
IsMsShippedOwned = true,
|
IsMsShippedOwned = true,
|
||||||
SortPriority = SmoTreeNode.NextSortPriority,
|
SortPriority = SmoTreeNode.NextSortPriority,
|
||||||
});
|
});
|
||||||
|
currentChildren.Add(new FolderNode {
|
||||||
|
NodeValue = SR.SchemaHierarchy_DroppedLedgerViews,
|
||||||
|
NodeType = "Folder",
|
||||||
|
NodeTypeId = NodeTypes.DroppedLedgerViews,
|
||||||
|
IsSystemObject = false,
|
||||||
|
IsMsShippedOwned = true,
|
||||||
|
SortPriority = SmoTreeNode.NextSortPriority,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override Type[] ChildQuerierTypes
|
internal override Type[] ChildQuerierTypes
|
||||||
@@ -1837,6 +1852,44 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Export(typeof(ChildFactory))]
|
||||||
|
[Shared]
|
||||||
|
internal partial class DroppedLedgerViewsChildFactory : SmoChildFactoryBase
|
||||||
|
{
|
||||||
|
public override IEnumerable<string> ApplicableParents() { return new[] { "DroppedLedgerViews" }; }
|
||||||
|
|
||||||
|
public override IEnumerable<INodeFilter> Filters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var filters = new List<INodeFilter>();
|
||||||
|
filters.Add(new NodePropertyFilter
|
||||||
|
{
|
||||||
|
Property = "IsDroppedLedgerView",
|
||||||
|
Type = typeof(bool),
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
|
Values = new List<object> { 1 },
|
||||||
|
});
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override Type[] ChildQuerierTypes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new [] { typeof(SqlViewQuerier), };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override TreeNode CreateChild(TreeNode parent, object context)
|
||||||
|
{
|
||||||
|
var child = new ViewTreeNode();
|
||||||
|
InitializeChild(parent, child, context);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Export(typeof(ChildFactory))]
|
[Export(typeof(ChildFactory))]
|
||||||
[Shared]
|
[Shared]
|
||||||
internal partial class ViewChildFactory : SmoChildFactoryBase
|
internal partial class ViewChildFactory : SmoChildFactoryBase
|
||||||
|
|||||||
@@ -99,8 +99,10 @@
|
|||||||
<Node Name="Views" LocLabel="SR.SchemaHierarchy_Views" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
<Node Name="Views" LocLabel="SR.SchemaHierarchy_Views" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
||||||
<Filters>
|
<Filters>
|
||||||
<Filter Property="IsSystemObject" Value="0" Type="bool" />
|
<Filter Property="IsSystemObject" Value="0" Type="bool" />
|
||||||
|
<Filter Property="IsDroppedLedgerView" Value="0" Type="bool" ValidFor="Sql2022|AzureV12"/>
|
||||||
</Filters>
|
</Filters>
|
||||||
<Child Name="SystemViews" IsSystemObject="1"/>
|
<Child Name="SystemViews" IsSystemObject="1"/>
|
||||||
|
<Child Name="DroppedLedgerViews" IsDroppedLedgerView="1"/>
|
||||||
</Node>
|
</Node>
|
||||||
|
|
||||||
<Node Name="Synonyms" LocLabel="SR.SchemaHierarchy_Synonyms" BaseClass="ModelBased" Strategy="MultipleElementsOfType" NodeType="Synonym" ChildQuerierTypes="SqlSynonym" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|Sql2017|Sql2019|Sql2022|AzureV12"/>
|
<Node Name="Synonyms" LocLabel="SR.SchemaHierarchy_Synonyms" BaseClass="ModelBased" Strategy="MultipleElementsOfType" NodeType="Synonym" ChildQuerierTypes="SqlSynonym" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|Sql2017|Sql2019|Sql2022|AzureV12"/>
|
||||||
@@ -249,6 +251,12 @@
|
|||||||
</Filters>
|
</Filters>
|
||||||
</Node>
|
</Node>
|
||||||
|
|
||||||
|
<Node Name="DroppedLedgerViews" LocLabel="SR.SchemaHierarchy_DroppedLedgerViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
||||||
|
<Filters>
|
||||||
|
<Filter Property="IsDroppedLedgerView" Value="1" Type="bool" ValidFor="Sql2022|AzureV12" />
|
||||||
|
</Filters>
|
||||||
|
</Node>
|
||||||
|
|
||||||
<Node Name="View" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" NodeType="View" Strategy="PopulateDetails">
|
<Node Name="View" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" NodeType="View" Strategy="PopulateDetails">
|
||||||
<Child Name="Columns"/>
|
<Child Name="Columns"/>
|
||||||
<Child Name="Triggers"/>
|
<Child Name="Triggers"/>
|
||||||
|
|||||||
@@ -51,6 +51,38 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Custom name for dropped ledger views
|
||||||
|
/// </summary>
|
||||||
|
internal partial class DroppedLedgerViewsChildFactory : SmoChildFactoryBase
|
||||||
|
{
|
||||||
|
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
View? view = smoObject as View;
|
||||||
|
if (view != null &&
|
||||||
|
IsPropertySupported("LedgerViewType", smoContext, view, CachedSmoProperties))
|
||||||
|
{
|
||||||
|
return $"{view.Schema}.{view.Name} ({SR.Ledger_LabelPart})";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {} //Ignore the exception and just not change create custom name
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext)
|
||||||
|
{
|
||||||
|
return "Ledger";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetNodePathName(object smoObject)
|
||||||
|
{
|
||||||
|
return ViewCustomNodeHelper.GetPathName(smoObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static class ViewCustomNodeHelper
|
internal static class ViewCustomNodeHelper
|
||||||
{
|
{
|
||||||
internal static string GetPathName(object smoObject)
|
internal static string GetPathName(object smoObject)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<<NonDeterministic>> SubType: Status:
|
NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<<NonDeterministic>> (Updatable Ledger) SubType:Ledger Status:
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||||
@@ -178,6 +178,15 @@ NodeType: Constraint Label: DF_Person_ModifiedDate SubType: Status:
|
|||||||
NodeType: Trigger Label: TableTrigger SubType: Status:
|
NodeType: Trigger Label: TableTrigger SubType: Status:
|
||||||
NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status:
|
||||||
NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status:
|
NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status:
|
||||||
|
NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<<NonDeterministic>> (Ledger) SubType:Ledger Status:
|
||||||
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
||||||
|
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
||||||
|
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
||||||
NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status:
|
NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status:
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
||||||
@@ -216,15 +225,6 @@ NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
|||||||
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
||||||
NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<<NonDeterministic>> (Ledger) SubType:Ledger Status:
|
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status:
|
|
||||||
NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status:
|
|
||||||
NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status:
|
|
||||||
NodeType: View Label: HumanResources.vEmployee SubType: Status:
|
NodeType: View Label: HumanResources.vEmployee SubType: Status:
|
||||||
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status:
|
||||||
NodeType: Column Label: Title (nvarchar(8), null) SubType: Status:
|
NodeType: Column Label: Title (nvarchar(8), null) SubType: Status:
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
|
|||||||
"testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/Databases/System Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/System Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/Databases/System Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn"
|
"testServer/Databases/System Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn"
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
||||||
@@ -113,7 +115,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
|
|||||||
"testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
||||||
"testServer/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn"
|
"testServer/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn"
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
||||||
|
|||||||
Reference in New Issue
Block a user