From 84ac316cdee3e9f8677e09c2e2fad14c6b0e5014 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 17 Aug 2015 15:05:44 +0200 Subject: [PATCH] IdoQuery: Allow check if a column is case insensitive compared refs #9029 --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 0c7276a68..85d9169a9 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -553,6 +553,31 @@ abstract class IdoQuery extends DbQuery return stripos($mapped, 'UNIX_TIMESTAMP') !== false; } + /** + * Return whether the given alias or column name provides case insensitive value comparison + * + * @param string $aliasOrColumn + * + * @return bool + */ + public function isCaseInsensitive($aliasOrColumn) + { + if ($this->isCustomVar($aliasOrColumn)) { + return false; + } + + $column = $this->getMappedField($aliasOrColumn) ?: $aliasOrColumn; + if (! $column) { + return false; + } + + if (! empty($this->columnsWithoutCollation)) { + return in_array($column, $this->columnsWithoutCollation) || strpos($column, 'LOWER') !== 0; + } + + return preg_match('/ COLLATE .+$/', $column) === 1; + } + /** * Apply oracle specific query initialization */