diff --git a/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.cs b/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.cs index 3196c63249..93d723f4b2 100644 --- a/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.cs +++ b/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.cs @@ -466,13 +466,13 @@ WHEN c.DATA_TYPE IN ('char', 'nchar', 'binary', 'varchar', 'nvarchar', 'varbinar WHEN c.CHARACTER_MAXIMUM_LENGTH = -1 THEN '(max)' ELSE '(' + CAST(c.CHARACTER_MAXIMUM_LENGTH AS NVARCHAR) + ')' END - WHEN c.DATA_TYPE IN ('datetime2', 'time', 'datetimeoffset') THEN '(' + CAST(c.NUMERIC_SCALE AS NVARCHAR) + ')' + WHEN c.DATA_TYPE IN ('datetime2', 'time', 'datetimeoffset') THEN '(' + CAST(c.DATETIME_PRECISION AS NVARCHAR) + ')' ELSE '' END + -- logic for null/notnull CASE - WHEN c.is_nullable = 'NO' THEN ', null' - ELSE ', not null' + WHEN c.is_nullable = 'NO' THEN ', not null' + ELSE ', null' END + ')' AS display_name, diff --git a/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.xml b/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.xml index fbd2e86dd3..0ed2b87e78 100644 --- a/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.xml +++ b/src/Microsoft.SqlTools.SqlCore/SimpleObjectExplorer/ObjectExplorerModel.xml @@ -135,13 +135,13 @@ WHEN c.CHARACTER_MAXIMUM_LENGTH = -1 THEN '(max)' ELSE '(' + CAST(c.CHARACTER_MAXIMUM_LENGTH AS NVARCHAR) + ')' END - WHEN c.DATA_TYPE IN ('datetime2', 'time', 'datetimeoffset') THEN '(' + CAST(c.NUMERIC_SCALE AS NVARCHAR) + ')' + WHEN c.DATA_TYPE IN ('datetime2', 'time', 'datetimeoffset') THEN '(' + CAST(c.DATETIME_PRECISION AS NVARCHAR) + ')' ELSE '' END + -- logic for null/notnull CASE - WHEN c.is_nullable = 'NO' THEN ', null' - ELSE ', not null' + WHEN c.is_nullable = 'NO' THEN ', not null' + ELSE ', null' END + ')' AS display_name, diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/SimpleObjectExplorerTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/SimpleObjectExplorerTests.cs index 15d48273dc..4a14fb34e7 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/SimpleObjectExplorerTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/ObjectExplorer/SimpleObjectExplorerTests.cs @@ -26,6 +26,8 @@ Create table t2 (c1 int) GO CREATE INDEX t2_idx ON t2 (c1) GO + Create table t3 (c1 int, c2 datetime2 NULL) + GO create view v1 WITH SCHEMABINDING as select c1 from dbo.t2 GO CREATE UNIQUE CLUSTERED INDEX v2_idx ON dbo.v1(c1) @@ -81,9 +83,10 @@ await RunTest(databaseName, query, "testdb", async (testdbName, connection) => // Expand Tables folder nodes = OE.GetNodeChildrenFromPath(oeRoot, "/dbo/Tables/"); - Assert.AreEqual(2, nodes.Length, "Tables folder should have 2 tables"); + Assert.AreEqual(3, nodes.Length, "Tables folder should have 3 tables"); Assert.IsNotNull(nodes.Find(node => node.Name == "t1"), "Tables folder should have t1 table"); Assert.IsNotNull(nodes.Find(node => node.Name == "t2"), "Tables folder should have t2 table"); + Assert.IsNotNull(nodes.Find(node => node.Name == "t3"), "Tables folder should have t3 table"); // Expand t1 table nodes = OE.GetNodeChildrenFromPath(oeRoot, "/dbo/Tables/t1/"); @@ -116,6 +119,11 @@ await RunTest(databaseName, query, "testdb", async (testdbName, connection) => Assert.AreEqual(1, nodes.Length, "Indexes folder should have 1 index"); Assert.IsNotNull(nodes.Find(node => node.Name == "t2_idx"), "Indexes folder should have t2_idx index"); + nodes = OE.GetNodeChildrenFromPath(oeRoot, "/dbo/Tables/t3/Columns/"); + Assert.AreEqual(2, nodes.Length, "Should have 2 columns"); + Assert.IsNotNull(nodes.Find(node => node.Name == "c2"), "Column c2 should exist"); + Assert.IsNotNull(nodes.Find(node => node.Label == "c2 (datetime2(7), null)"), "Display Name for a c2 should have datetime 2 and null"); + // Expand Views folder nodes = OE.GetNodeChildrenFromPath(oeRoot, "/dbo/Views/"); Assert.AreEqual(1, nodes.Length, "Views folder should have 1 view");