[Mpuls-commits] r5462 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 12 20:02:33 CEST 2011


Author: bh
Date: 2011-10-12 20:02:30 +0200 (Wed, 12 Oct 2011)
New Revision: 5462

Modified:
   base/trunk/mpulsweb/lib/search.py
Log:
Do not match NULL when searching cases for a given string.
More precisely, if the user has supplied a string to search for, do not
consider a case to match the criteria, all the fields in the case that
will be compared to the string are NULL.

This NULL-matching was introduced when anonymization was added to
mpuls. The reason apparently was that otherwise anonymized cases could
never match a search because the string comparison was always done, even
if the user didn't actually input a search string. The current code in
mpuls will only do the comparison when the user has actually provided a
search string, so the NULL check can be omitted.


Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2011-10-12 16:32:05 UTC (rev 5461)
+++ base/trunk/mpulsweb/lib/search.py	2011-10-12 18:02:30 UTC (rev 5462)
@@ -344,13 +344,9 @@
         """
         search = options.get("search_string", ())
         if search and self.match_fields:
-            needle_expr = ("((%s) OR (%s))"
-                           % (" OR ".join("m.%s ~* '%%(needle)s'"
-                                          % field
-                                          for field in self.match_fields),
-                              " AND ".join("m.%s IS NULL"
-                                           % field
-                                           for field in self.match_fields)))
+            needle_expr = ("(%s)"
+                           % (" OR ".join("m.%s ~* '%%(needle)s'" % field
+                                          for field in self.match_fields)))
             return needle_expr % dict(needle=" ".join(search))
         return "TRUE"
 
@@ -557,13 +553,10 @@
         """
         search = options.get("search_string", ())
         if search and self.match_fields:
-            needle_expr = ("((%s) OR (%s))"
+            needle_expr = ("(%s)"
                            % (" OR ".join("f.%s ~* '%%(needle)s'"
                                           % field
-                                          for field in self.match_fields),
-                              " AND ".join("f.%s IS NULL"
-                                           % field
-                                           for field in self.match_fields)))
+                                          for field in self.match_fields)))
             return needle_expr % dict(needle=" ".join(search))
         return "TRUE"
 



More information about the Mpuls-commits mailing list