]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/logging.py
fix linting issues
[nominatim.git] / nominatim / api / logging.py
index 202d7de9a5baf0abca6ed1807bfb488cb136de05..3160ede8f53b01027ee17ffd8ef01d497f38fc9e 100644 (file)
@@ -80,7 +80,8 @@ class BaseLogger:
         """
 
     def format_sql(self, conn: AsyncConnection, statement: 'sa.Executable',
-                   extra_params: Union[Mapping[str, Any], Sequence[Mapping[str, Any]], None]) -> str:
+                   extra_params: Union[Mapping[str, Any],
+                                 Sequence[Mapping[str, Any]], None]) -> str:
         """ Return the comiled version of the statement.
         """
         compiled = cast('sa.ClauseElement', statement).compile(conn.sync_engine)
@@ -95,13 +96,14 @@ class BaseLogger:
 
         sqlstr = str(compiled)
 
-        if '%s' in sqlstr:
+        if sa.__version__.startswith('1'):
             try:
-                return sqlstr % tuple((repr(compiled.params[name]) for name in compiled.positiontup))
+                return sqlstr % tuple((repr(params.get(name, None))
+                                      for name in compiled.positiontup)) # type: ignore
             except TypeError:
                 return sqlstr
 
-        return str(compiled) % params
+        return sqlstr % params
 
 
 class HTMLLogger(BaseLogger):