svn keywords
[plcapi.git] / PLC / PostgreSQL.py
index 9dcae20..101cfe6 100644 (file)
@@ -6,6 +6,7 @@
 # Copyright (C) 2006 The Trustees of Princeton University
 #
 # $Id$
+# $URL$
 #
 
 import psycopg2
@@ -166,8 +167,13 @@ class PostgreSQL:
 
             # psycopg2 requires %()s format for all parameters,
             # regardless of type.
+            # this needs to be done carefully though as with pattern-based filters
+            # we might have percents embedded in the query
+            # so e.g. GetPersons({'email':'*fake*'}) was resulting in .. LIKE '%sake%'
             if psycopg2:
                 query = re.sub(r'(%\([^)]*\)|%)[df]', r'\1s', query)
+            # rewrite wildcards set by Filter.py as '***' into '%'
+            query = query.replace ('***','%')
 
             if not params:
                 if self.debug: