Merge pull request #4179 from Icinga/fix/case-insensitive-membership-tests-on-postgres-4178

Fix case insensitive membership filters on Postgres
This commit is contained in:
Johannes Meyer 2020-06-17 13:24:12 +02:00 committed by GitHub
commit bf677ac29d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -568,6 +568,13 @@ abstract class IdoQuery extends DbQuery
$and = false; $and = false;
} }
$alias = $filter->getColumn();
$column = $subQuery->aliasToColumnName($alias);
if (isset($this->caseInsensitiveColumns[$subQuery->aliasToTableName($alias)][$alias])) {
$column = 'LOWER( ' . $column . ' )';
$subQueryFilter->setExpression(array_map('strtolower', $subQueryFilter->getExpression()));
}
$additional = null; $additional = null;
list($theirs, $ours) = $this->joinSubQuery($subQuery, $queryName, $subQueryFilter, $and, $negate, $additional); list($theirs, $ours) = $this->joinSubQuery($subQuery, $queryName, $subQueryFilter, $and, $negate, $additional);
@ -620,7 +627,7 @@ abstract class IdoQuery extends DbQuery
$subQueryFilter->setColumn(preg_replace( $subQueryFilter->setColumn(preg_replace(
'/(?<=^|\s)\w+(?=\.)/', '/(?<=^|\s)\w+(?=\.)/',
'sub_$0', 'sub_$0',
$subQuery->aliasToColumnName($filter->getColumn()) $column
)); ));
if ($negate) { if ($negate) {