Skip to content

Commit

Permalink
Fix SimpleObjectExplorer bugs (#2382)
Browse files Browse the repository at this point in the history
* Fix simple OE bugs

* Add test for SimpleObjectExplorer fixes
  • Loading branch information
mykolian authored Aug 6, 2024
1 parent 649b2b8 commit a6cdd85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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/");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a6cdd85

Please sign in to comment.