mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Dropped Ledger Columns folders for ledger primary tables (#1688)
* dropped ledger columns strings, nodetypes, definition * work in progress * WIP- dropped columns folder showing for all tables * Dropped Ledger Column folder only for primary ledger tables * cleaning up * undoing changes to kusto layer * formatting * undoing formatting * undoing formatting * removing IsLedger property and instead filtering on NodeTypeId * updating column path test
This commit is contained in:
@@ -2045,6 +2045,14 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string SchemaHierarchy_DroppedLedgerColumns
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Keys.GetString(Keys.SchemaHierarchy_DroppedLedgerColumns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string SchemaHierarchy_DroppedLedgerTables
|
public static string SchemaHierarchy_DroppedLedgerTables
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -10877,6 +10885,9 @@ namespace Microsoft.SqlTools.ServiceLayer
|
|||||||
public const string SchemaHierarchy_ExternalTables = "SchemaHierarchy_ExternalTables";
|
public const string SchemaHierarchy_ExternalTables = "SchemaHierarchy_ExternalTables";
|
||||||
|
|
||||||
|
|
||||||
|
public const string SchemaHierarchy_DroppedLedgerColumns = "SchemaHierarchy_DroppedLedgerColumns";
|
||||||
|
|
||||||
|
|
||||||
public const string SchemaHierarchy_DroppedLedgerTables = "SchemaHierarchy_DroppedLedgerTables";
|
public const string SchemaHierarchy_DroppedLedgerTables = "SchemaHierarchy_DroppedLedgerTables";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1280,6 +1280,10 @@
|
|||||||
<value>External Tables</value>
|
<value>External Tables</value>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SchemaHierarchy_DroppedLedgerColumns" xml:space="preserve">
|
||||||
|
<value>Dropped Ledger Columns</value>
|
||||||
|
<comment></comment>
|
||||||
|
</data>
|
||||||
<data name="SchemaHierarchy_DroppedLedgerTables" xml:space="preserve">
|
<data name="SchemaHierarchy_DroppedLedgerTables" xml:space="preserve">
|
||||||
<value>Dropped Ledger Tables</value>
|
<value>Dropped Ledger Tables</value>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
|
|||||||
@@ -630,6 +630,8 @@ SchemaHierarchy_ExternalResources = External Resources
|
|||||||
|
|
||||||
SchemaHierarchy_ExternalTables = External Tables
|
SchemaHierarchy_ExternalTables = External Tables
|
||||||
|
|
||||||
|
SchemaHierarchy_DroppedLedgerColumns = Dropped Ledger Columns
|
||||||
|
|
||||||
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
|
SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables
|
||||||
|
|
||||||
SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views
|
SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views
|
||||||
|
|||||||
@@ -6331,6 +6331,11 @@ The Query Processor estimates that implementing the following index could improv
|
|||||||
<target state="new">Dropped Ledger Views</target>
|
<target state="new">Dropped Ledger Views</target>
|
||||||
<note></note>
|
<note></note>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="SchemaHierarchy_DroppedLedgerColumns">
|
||||||
|
<source>Dropped Ledger Columns</source>
|
||||||
|
<target state="new">Dropped Ledger Columns</target>
|
||||||
|
<note></note>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="SqlProjectModelNotFound">
|
<trans-unit id="SqlProjectModelNotFound">
|
||||||
<source>Could not find SQL model from project: {0}.</source>
|
<source>Could not find SQL model from project: {0}.</source>
|
||||||
<target state="new">Could not find SQL model from project: {0}.</target>
|
<target state="new">Could not find SQL model from project: {0}.</target>
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
bool anyDroppedFolders = this.Any(
|
bool anyDroppedFolders = this.Any(
|
||||||
node => node is FolderNode &&
|
node => node is FolderNode &&
|
||||||
(node.NodeTypeId == NodeTypes.DroppedLedgerTables ||
|
(node.NodeTypeId == NodeTypes.DroppedLedgerTables ||
|
||||||
node.NodeTypeId == NodeTypes.DroppedLedgerViews));
|
node.NodeTypeId == NodeTypes.DroppedLedgerViews ||
|
||||||
|
node.NodeTypeId == NodeTypes.DroppedLedgerColumns));
|
||||||
return this.FirstOrDefault() is SmoTreeNode && !anyDroppedFolders;
|
return this.FirstOrDefault() is SmoTreeNode && !anyDroppedFolders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,5 +142,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
|||||||
ColumnEncryptionKeys,
|
ColumnEncryptionKeys,
|
||||||
DroppedLedgerTables,
|
DroppedLedgerTables,
|
||||||
DroppedLedgerViews,
|
DroppedLedgerViews,
|
||||||
|
DroppedLedgerColumns,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
allChildren.RemoveAll(x => x.IsSystemObject);
|
allChildren.RemoveAll(x => x.IsSystemObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context != null && context.ValidFor != 0 && context.ValidFor != ValidForFlag.All)
|
if (context != null && context.ValidFor != 0 && context.ValidFor != ValidForFlag.All)
|
||||||
{
|
{
|
||||||
allChildren.RemoveAll(x =>
|
allChildren.RemoveAll(x =>
|
||||||
@@ -64,6 +65,22 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove the Dropped Ledger Columns folder if this isn't under a ledger table
|
||||||
|
allChildren.RemoveAll(x =>
|
||||||
|
{
|
||||||
|
if (x.NodeTypeId == NodeTypes.DroppedLedgerColumns)
|
||||||
|
{
|
||||||
|
Table? parentTable = context.Parent as Table;
|
||||||
|
if (parentTable == null ||
|
||||||
|
!(parentTable.LedgerType == LedgerTableType.UpdatableLedgerTable ||
|
||||||
|
parentTable.LedgerType == LedgerTableType.AppendOnlyLedgerTable))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
Name = "XmlDocumentConstraint",
|
Name = "XmlDocumentConstraint",
|
||||||
ValidFor = ValidForFlag.NotSqlDw
|
ValidFor = ValidForFlag.NotSqlDw
|
||||||
|
},
|
||||||
|
new NodeSmoProperty
|
||||||
|
{
|
||||||
|
Name = "IsDroppedLedgerColumn",
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1644,6 +1644,34 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
{
|
{
|
||||||
public override IEnumerable<string> ApplicableParents() { return new[] { "Columns" }; }
|
public override IEnumerable<string> ApplicableParents() { return new[] { "Columns" }; }
|
||||||
|
|
||||||
|
public override IEnumerable<INodeFilter> Filters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var filters = new List<INodeFilter>();
|
||||||
|
filters.Add(new NodePropertyFilter
|
||||||
|
{
|
||||||
|
Property = "IsDroppedLedgerColumn",
|
||||||
|
Type = typeof(bool),
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
|
Values = new List<object> { 0 },
|
||||||
|
});
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
|
||||||
|
{
|
||||||
|
currentChildren.Add(new FolderNode {
|
||||||
|
NodeValue = SR.SchemaHierarchy_DroppedLedgerColumns,
|
||||||
|
NodeType = "Folder",
|
||||||
|
NodeTypeId = NodeTypes.DroppedLedgerColumns,
|
||||||
|
IsSystemObject = false,
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
|
SortPriority = Int32.MaxValue,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
internal override Type[] ChildQuerierTypes
|
internal override Type[] ChildQuerierTypes
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -1663,6 +1691,46 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Export(typeof(ChildFactory))]
|
||||||
|
[Shared]
|
||||||
|
internal partial class DroppedLedgerColumnsChildFactory : SmoChildFactoryBase
|
||||||
|
{
|
||||||
|
public override IEnumerable<string> ApplicableParents() { return new[] { "DroppedLedgerColumns" }; }
|
||||||
|
|
||||||
|
public override IEnumerable<INodeFilter> Filters
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var filters = new List<INodeFilter>();
|
||||||
|
filters.Add(new NodePropertyFilter
|
||||||
|
{
|
||||||
|
Property = "IsDroppedLedgerColumn",
|
||||||
|
Type = typeof(bool),
|
||||||
|
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||||
|
Values = new List<object> { 1 },
|
||||||
|
});
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override Type[] ChildQuerierTypes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new [] { typeof(SqlColumnQuerier), };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override TreeNode CreateChild(TreeNode parent, object context)
|
||||||
|
{
|
||||||
|
var child = new SmoTreeNode();
|
||||||
|
child.IsAlwaysLeaf = true;
|
||||||
|
child.NodeType = "Column";
|
||||||
|
InitializeChild(parent, child, context);
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Export(typeof(ChildFactory))]
|
[Export(typeof(ChildFactory))]
|
||||||
[Shared]
|
[Shared]
|
||||||
internal partial class KeysChildFactory : SmoChildFactoryBase
|
internal partial class KeysChildFactory : SmoChildFactoryBase
|
||||||
|
|||||||
@@ -224,7 +224,19 @@
|
|||||||
<Child Name="Statistics"/>
|
<Child Name="Statistics"/>
|
||||||
</Node>
|
</Node>
|
||||||
|
|
||||||
<Node Name="Columns" LocLabel="SR.SchemaHierarchy_Columns" BaseClass="ModelBased" Strategy="PopulateParentDetails" NodeType="Column" ChildQuerierTypes="SqlColumn" DisableSort=""/>
|
<Node Name="Columns" LocLabel="SR.SchemaHierarchy_Columns" BaseClass="ModelBased" Strategy="PopulateParentDetails" NodeType="Column" ChildQuerierTypes="SqlColumn" DisableSort="">
|
||||||
|
<Filters>
|
||||||
|
<Filter Property="IsDroppedLedgerColumn" Value="0" Type="bool" ValidFor="Sql2022|AzureV12" />
|
||||||
|
</Filters>
|
||||||
|
<Child Name="DroppedLedgerColumns"/>
|
||||||
|
</Node>
|
||||||
|
|
||||||
|
<Node Name="DroppedLedgerColumns" LocLabel="SR.SchemaHierarchy_DroppedLedgerColumns" BaseClass="ModelBased" Strategy="PopulateParentDetails" NodeType="Column" ChildQuerierTypes="SqlColumn" ValidFor="Sql2022|AzureV12" SortPriority="Int32.MaxValue">
|
||||||
|
<Filters>
|
||||||
|
<Filter Property="IsDroppedLedgerColumn" Value="1" Type="bool" ValidFor="Sql2022|AzureV12" />
|
||||||
|
</Filters>
|
||||||
|
</Node>
|
||||||
|
|
||||||
<Node Name="Keys" LocLabel="SR.SchemaHierarchy_Keys" BaseClass="ModelBased" Strategy="ElementsInRelationship" NodeType="Key" ChildQuerierTypes="SqlIndex;SqlForeignKeyConstraint" ValidFor="NotSqlDw">
|
<Node Name="Keys" LocLabel="SR.SchemaHierarchy_Keys" BaseClass="ModelBased" Strategy="ElementsInRelationship" NodeType="Key" ChildQuerierTypes="SqlIndex;SqlForeignKeyConstraint" ValidFor="NotSqlDw">
|
||||||
<Filters>
|
<Filters>
|
||||||
<Filter TypeToReverse="SqlIndex" Property="IndexKeyType" Type="Enum" ValidFor="AllOnPrem|AzureV12">
|
<Filter TypeToReverse="SqlIndex" Property="IndexKeyType" Type="Enum" ValidFor="AllOnPrem|AzureV12">
|
||||||
|
|||||||
@@ -700,6 +700,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
|
|||||||
filterExpressions.Add("@GeneratedAlwaysType=0");
|
filterExpressions.Add("@GeneratedAlwaysType=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we're called for EDIT for SQL2022+/Sterling+.
|
||||||
|
// We need to omit dropped ledger columns if such are present
|
||||||
if (server.Version.Major >= 16 || (DatabaseEngineType.SqlAzureDatabase == server.DatabaseEngineType && server.Version.Major >= 12))
|
if (server.Version.Major >= 16 || (DatabaseEngineType.SqlAzureDatabase == server.DatabaseEngineType && server.Version.Major >= 12))
|
||||||
{
|
{
|
||||||
filterExpressions.Add("@IsDroppedLedgerColumn=0");
|
filterExpressions.Add("@IsDroppedLedgerColumn=0");
|
||||||
|
|||||||
@@ -85,17 +85,29 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
|
|||||||
var expectedPaths = new List<string>
|
var expectedPaths = new List<string>
|
||||||
{
|
{
|
||||||
"testServer/Databases/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/System Databases/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/System Databases/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/System Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/System Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Tables/System Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/System Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/System Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/System 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/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
"testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/Dropped Ledger 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/System Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/Databases/testDatabase/Views/Dropped Ledger 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"
|
"testServer/Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/Databases/System Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn"
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
||||||
@@ -112,11 +124,17 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
|
|||||||
var expectedPaths = new List<string>
|
var expectedPaths = new List<string>
|
||||||
{
|
{
|
||||||
"testServer/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
"testServer/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
"testServer/testDatabase/Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Views/testSchema.testTable/Columns/Dropped Ledger 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"
|
"testServer/testDatabase/Views/System Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn",
|
||||||
|
"testServer/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/Dropped Ledger Columns/testColumn"
|
||||||
};
|
};
|
||||||
|
|
||||||
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
Assert.AreEqual(expectedPaths.Count, paths.Count);
|
||||||
|
|||||||
Reference in New Issue
Block a user