Skip to content

Commit 00ac4fc

Browse files
fix sorting
1 parent deec27e commit 00ac4fc

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

Sql/DotNetThoughts.Sql.Inspection/DotNetThoughts.Sql.Inspection.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Version>0.0.5</Version>
4+
<Version>0.0.6</Version>
55
<GenerateDocumentationFile>True</GenerateDocumentationFile>
66
<PackageLicenseExpression>MIT</PackageLicenseExpression>
77
</PropertyGroup>

Sql/DotNetThoughts.Sql.Inspection/ViewDependencySorter.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ public int Compare(Schema.ViewInfo? x, Schema.ViewInfo? y)
1616
{
1717
throw new Exception("Cant order nulls.");
1818
}
19-
if (!_view_viewDependencies.Any(d => d.referencing_id == x.object_id || d.referenced_id == x.object_id))
20-
{
21-
// x is not referenced or referencing on anyone
22-
return 0;
23-
}
24-
if (!_view_viewDependencies.Any(d => d.referencing_id == y.object_id || d.referenced_id == y.object_id))
25-
{
26-
// y is not referenced or referencing on anyone
27-
return 0;
28-
}
2919
if (x.object_id == y.object_id)
3020
{
3121
// x and y are the same
@@ -41,6 +31,21 @@ public int Compare(Schema.ViewInfo? x, Schema.ViewInfo? y)
4131
// x is referenced by y
4232
return -1;
4333
}
34+
if ((!_view_viewDependencies.Any(d => d.referencing_id == x.object_id || d.referenced_id == x.object_id)) && (!_view_viewDependencies.Any(d => d.referencing_id == y.object_id || d.referenced_id == y.object_id)))
35+
{
36+
// x is not referenced or referencing on anyone
37+
return 0;
38+
}
39+
if (!_view_viewDependencies.Any(d => d.referencing_id == x.object_id || d.referenced_id == x.object_id))
40+
{
41+
// x is not referenced or referencing on anyone
42+
return -1;
43+
}
44+
if (!_view_viewDependencies.Any(d => d.referencing_id == y.object_id || d.referenced_id == y.object_id))
45+
{
46+
// y is not referenced or referencing on anyone
47+
return 1;
48+
}
4449
return 0;
4550
}
4651
}

0 commit comments

Comments
 (0)