Skip to content

Commit

Permalink
FlattenedObjectVars: Only avoid relation traversing...
Browse files Browse the repository at this point in the history
...if customvar_flat isn't being selected and it is
guaranteed that ipl-orm will outsource the condition
to a subquery.

fixes #1020
  • Loading branch information
nilmerg committed Jul 22, 2024
1 parent dd943af commit c7dae01
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/Icingadb/Model/Behavior/FlattenedObjectVars.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public function rewriteCondition(Filter\Condition $condition, $relation = null)
->set('columnPath', $relation . $column)
->set('relationPath', substr($relation, 0, -1));

if (isset($this->query->getWith()[substr($relation, 0, -1)])) {
// In case customvar_flat is being selected, the FilterProcessor will not try to optimize the condition.
// So we can prepare the condition here and still let CustomvarFlat's behavior do the rest.
$condition->metaData()->set('columnName', $relation . $column);

return $condition;
}

// The ORM's FilterProcessor only optimizes filter conditions that are in the same level (chain).
// Previously, this behavior transformed a single condition to an ALL chain and hence the semantics
// of the level changed, since the FilterProcessor interpreted the conditions separately from there on.
Expand Down

0 comments on commit c7dae01

Please sign in to comment.