[icinga-checkins] icinga.org: icingaweb2/feature/actiontable-row-handling-13115: DbConnection: Explicitly check for NULL when rendering unequal filters

git at icinga.org git at icinga.org
Wed Nov 16 10:39:05 CET 2016


Module: icingaweb2
Branch: feature/actiontable-row-handling-13115
Commit: 634a69aec9c20d0ff2e1b589b0e22b7e2b5bc51b
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=634a69aec9c20d0ff2e1b589b0e22b7e2b5bc51b

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Fri Nov 11 09:17:58 2016 +0100

DbConnection: Explicitly check for NULL when rendering unequal filters

resolves #12852

---

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

diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php
index 81afb2c..9705bff 100644
--- a/library/Icinga/Data/Db/DbConnection.php
+++ b/library/Icinga/Data/Db/DbConnection.php
@@ -444,7 +444,7 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
             if ($sign === '=') {
                 return $column . ' IN (' . $this->dbAdapter->quote($value) . ')';
             } elseif ($sign === '!=') {
-                return $column . ' NOT IN (' . $this->dbAdapter->quote($value) . ')';
+                return sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $column, $this->dbAdapter->quote($value));
             }
 
             throw new ProgrammingError(
@@ -467,9 +467,15 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
                 return $this->dbAdapter->quote(0);
             }
 
-            return $column . ' NOT LIKE ' . $this->dbAdapter->quote(preg_replace('~\*~', '%', $value));
+            return sprintf(
+                '(%1$s NOT LIKE %2$s OR %1$s IS NULL)',
+                $column,
+                $this->dbAdapter->quote(preg_replace('~\*~', '%', $value))
+            );
+        } elseif ($sign === '!=') {
+            return sprintf('(%1$s != %2$s OR %1$s IS NULL)', $column, $this->dbAdapter->quote($value));
         } else {
-            return $column . ' ' . $sign . ' ' . $this->dbAdapter->quote($value);
+            return sprintf('%s %s %s', $column, $sign, $this->dbAdapter->quote($value));
         }
     }
 



More information about the icinga-checkins mailing list