Skip to content

Fix half baked relation filter workaround - #183

Open
nilmerg wants to merge 4 commits into
mainfrom
fix/half-baked-relation-filter-workaround-182
Open

nilmerg wants to merge 4 commits into
mainfrom
fix/half-baked-relation-filter-workaround-182

Conversation

@nilmerg

@nilmerg nilmerg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

This includes changes to how a reversed relation's filter is preserved and how the filter processor deals with IS NULL checks.

The latter is yet another reason I'd want to re-write the entire filter implementation from scratch, but that is still out of the question since it breaks every existing negation handling.

fixes #182

Always override the inverse relation filter with what the forward relation
provides. This is especially important for re-used relations where the
configured filter may have different semantics. If semantics should be
equal, both relations must have explicitly set filters.
It's not required anymore due to how relation
reversal eagerly creates missing ones now.
@nilmerg
nilmerg force-pushed the fix/half-baked-relation-filter-workaround-182 branch from 3231b60 to dbe5979 Compare November 24, 2026 10:46
@nilmerg
nilmerg marked this pull request as ready for review November 24, 2026 10:49
Comment thread src/Compat/FilterProcessor.php Outdated
$positive = [];
foreach ($rules as $rule) {
if ($rule->metaData()->get('treat-positively', false)) {
if (! $rule->getValue() === '*') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use !==, I am surprised PHPStorm doesn't flag the throw as unreachable.

Comment thread src/Compat/FilterProcessor.php Outdated
Comment on lines +263 to +264
// An unlike comparison with a value of '*' might a special case. It is used to filter for
// NULL values and so may semantically equivalent to a positive comparison, not a negation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... might be ... may be ...

Comment thread tests/FilterProcessorTest.php Outdated
$this->assertSame('Pluto', $results[0]->name);
$this->assertSame('Donald', $results[1]->name);

// TODO: Should this really use having?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a leftover?

My first attempt was to handle such differently by default, but this leads
to different results in e.g. Icinga DB Web when filtering for a custom
variable this way. So, my only solution right now is to introduce yet
another work-around using meta data. Negated condition support is a mess
already and so I am not convinced to further invest time in a better
alternative.
@nilmerg
nilmerg force-pushed the fix/half-baked-relation-filter-workaround-182 branch from dbe5979 to d925b07 Compare November 24, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty filter on the forward relation uses the reverse's filter in subqueries

2 participants