]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/logging.py
Merge pull request #3167 from lonvia/explicit-encoding
[nominatim.git] / nominatim / api / logging.py
index 3785579073a71df7544518b407c5f34b173664ca..5b6d0e4dbbc03573b643e88cba43a871d7bd038a 100644 (file)
@@ -99,6 +99,7 @@ class BaseLogger:
 
         if sa.__version__.startswith('1'):
             try:
+                sqlstr = re.sub(r'__\[POSTCOMPILE_[^]]*\]', '%s', sqlstr)
                 return sqlstr % tuple((repr(params.get(name, None))
                                       for name in compiled.positiontup)) # type: ignore
             except TypeError:
@@ -107,9 +108,9 @@ class BaseLogger:
         # Fixes an odd issue with Python 3.7 where percentages are not
         # quoted correctly.
         sqlstr = re.sub(r'%(?!\()', '%%', sqlstr)
+        sqlstr = re.sub(r'__\[POSTCOMPILE_([^]]*)\]', r'%(\1)s', sqlstr)
         return sqlstr % params
 
-
 class HTMLLogger(BaseLogger):
     """ Logger that formats messages in HTML.
     """