Skip to content

Pin the relationship filter to the JOIN ON clause - #1235

Merged
mastacontrola merged 1 commit into
working-1.6from
relfilter-test
Aug 20, 2026
Merged

Pin the relationship filter to the JOIN ON clause#1235
mastacontrola merged 1 commit into
working-1.6from
relfilter-test

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

1cd7446f6 (June) 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 — no server, no rows. It asserts

  • the filter is still declared (or every other check passes vacuously),
  • it lands in the ON clause,
  • the join is still LEFT OUTER,
  • and 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.

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.

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>
@mastacontrola
mastacontrola merged commit 6a402bd into working-1.6 Aug 20, 2026
7 checks passed
@mastacontrola
mastacontrola deleted the relfilter-test branch August 20, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants