-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The StripUnusedJoins logic strips a view reference when only 1 column remains after column stripping (case 1 when options.StripUnusedJoins in DatabaseViewInliner.cs). However, it doesn't distinguish between:
- A join where the remaining column is only used in the ON clause (correct to strip)
- A view where the remaining column is actively selected (incorrect to strip)
Example
-- Inner view
CREATE VIEW dbo.VItems AS SELECT a.Id, a.Name FROM dbo.A a INNER JOIN dbo.B b ON a.BId = b.Id
-- Outer view: selects v.Id — this IS selected data
CREATE VIEW dbo.VTest AS SELECT v.Id FROM dbo.VItems vAfter column stripping, VItems has 1 column (Id). The 1-column rule adds VItems to toRemove and skips toReplace, so VItems ends up neither inlined nor removed in the output.
Expected behavior
VItems should be inlined normally since its remaining column is used in the SELECT, not just in a join condition.
Priority
Low — unlikely to occur in production since views typically have 2+ useful columns.
Possible fix
Check whether the remaining column is referenced in the outer SELECT (not just in a JOIN ON clause) before applying the strip rule.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working