]> git.openstreetmap.org Git - nominatim.git/commitdiff
add support for postcompile literals in debug output
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 6 Jul 2023 07:29:20 +0000 (09:29 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 6 Jul 2023 10:16:57 +0000 (12:16 +0200)
nominatim/api/logging.py

index 3785579073a71df7544518b407c5f34b173664ca..d4dc68b7bc126e3fc9da339d89c86b640e91fb9f 100644 (file)
@@ -99,6 +99,7 @@ class BaseLogger:
 
         if sa.__version__.startswith('1'):
             try:
 
         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:
                 return sqlstr % tuple((repr(params.get(name, None))
                                       for name in compiled.positiontup)) # type: ignore
             except TypeError:
@@ -107,9 +108,10 @@ class BaseLogger:
         # Fixes an odd issue with Python 3.7 where percentages are not
         # quoted correctly.
         sqlstr = re.sub(r'%(?!\()', '%%', sqlstr)
         # 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)
+        print(sqlstr)
         return sqlstr % params
 
         return sqlstr % params
 
-
 class HTMLLogger(BaseLogger):
     """ Logger that formats messages in HTML.
     """
 class HTMLLogger(BaseLogger):
     """ Logger that formats messages in HTML.
     """