[icinga-checkins] icinga.org: icingaweb2/feature/announce-banner-11198: DbQuery: handle strange NULL comparision results

git at icinga.org git at icinga.org
Fri Nov 4 10:50:04 CET 2016


Module: icingaweb2
Branch: feature/announce-banner-11198
Commit: 7d94c1fddbce7fa9aa31ae08b87e4d25bec191cb
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=7d94c1fddbce7fa9aa31ae08b87e4d25bec191cb

Author: Alexander A. Klimov <alexander.klimov at icinga.com>
Date:   Thu Oct 20 15:40:33 2016 +0200

DbQuery: handle strange NULL comparision results

refs #12852

---

 library/Icinga/Data/Db/DbQuery.php |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php
index 48607b6..966e094 100644
--- a/library/Icinga/Data/Db/DbQuery.php
+++ b/library/Icinga/Data/Db/DbQuery.php
@@ -301,7 +301,7 @@ class DbQuery extends SimpleQuery
             if ($sign === '=') {
                 return $col . ' IN (' . $this->escapeForSql($expression) . ')';
             } elseif ($sign === '!=') {
-                return $col . ' NOT IN (' . $this->escapeForSql($expression) . ')';
+                return $col . ' NOT IN (' . $this->escapeForSql($expression) . ') OR ' . $col . ' IS NULL';
             }
 
             throw new QueryException('Unable to render array expressions with operators other than equal or not equal');
@@ -316,9 +316,12 @@ class DbQuery extends SimpleQuery
                 return new Zend_Db_Expr('FALSE');
             }
 
-            return $col . ' NOT LIKE ' . $this->escapeForSql($this->escapeWildcards($expression));
+            return $col . ' NOT LIKE ' . $this->escapeForSql($this->escapeWildcards($expression))
+                . ' OR ' . $col . ' IS NULL';
         } else {
-            return $col . ' ' . $sign . ' ' . $this->escapeForSql($expression);
+            return $col . ' ' . $sign . ' ' . $this->escapeForSql($expression) . (
+                $sign === '!=' ? ' OR ' . $col . ' IS NULL' : ''
+            );
         }
     }
 



More information about the icinga-checkins mailing list