Pin the relationship filter to the JOIN ON clause - #1235
Merged
Conversation
1cd7446 moved the relationship map's optional 4th element out of the WHERE clause and into the join's ON clause, and shipped no test. This is that test. The filter it protects is the only one in the codebase: 'MACAddressAssociation' => ['hostID', 'id', 'primac', ['primary' => 1]] and a WHERE predicate on the right-hand table of a LEFT OUTER JOIN is not a filter -- it is an INNER JOIN written the long way, which dropped any host with no hmPrimary='1' row out of its own query. buildQuery() recurses, so it took Task, SnapinJob, SnapinTask, ImagingLog, NodeFailure, UserTracking and OUAssociation with it. Structural, and deliberately so: the defect is in the SQL text, so the SQL text is what it reads, and it runs where CI runs -- with no server and no rows. It asserts the filter is still declared (or every other check would pass vacuously), that it lands in the ON clause, that the join is still LEFT OUTER, and that no class reaching Host puts a hostMAC predicate in WHERE. Each gate mutation-verified against this branch's own fix: emitting the filter to WHERE fails 9 checks, turning the join INNER fails 1, dropping the filter fails 1. dev-branch gets the same file, plus a behavioural counterpart that drives real rows, in #1234. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1cd7446f6(June) moved the relationship map's optional 4th element out of the WHERE clause and into the join'sONclause, and shipped no test. This is that test.The filter it protects is the only one in the codebase:
and a WHERE predicate on the right-hand table of a LEFT OUTER JOIN is not a filter — it is an INNER JOIN written the long way, which dropped any host with no
hmPrimary='1'row out of its own query.buildQuery()recurses, so it tookTask,SnapinJob,SnapinTask,ImagingLog,NodeFailure,UserTrackingandOUAssociationwith it.Structural, and deliberately so: the defect is in the SQL text, so the SQL text is what it reads, and it runs where CI runs — no server, no rows. It asserts
ONclause,LEFT OUTER,Hostputs ahostMACpredicate in WHERE.Each gate mutation-verified against this branch's own fix: emitting the filter to WHERE fails 9 checks, turning the join INNER fails 1, dropping the filter fails 1.
sh tests/run-all.sh— 77 passed, 0 failed.No production code changes here. dev-branch gets the same file plus the fix itself, and a behavioural counterpart that drives real rows, in #1234.