]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 17 Sep 2023 15:10:35 +0000 (17:10 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sun, 17 Sep 2023 15:10:35 +0000 (17:10 +0200)
nominatim/api/search/db_search_builder.py
nominatim/db/async_connection.py
nominatim/db/connection.py
nominatim/db/utils.py

index 03e78d45ed3d36ddd85048aef2aa9bfd437185c5..66e7efaf7f729dec8fdc8f0f889295b6ed8a6f67 100644 (file)
@@ -206,7 +206,7 @@ class SearchBuilder:
 
         partials_indexed = all(t.is_indexed for t in name_partials) \
                            and all(t.is_indexed for t in addr_partials)
-        exp_count = min(t.count for t in name_partials)
+        exp_count = min(t.count for t in name_partials) / (2**(len(name_partials) - 1))
 
         if (len(name_partials) > 3 or exp_count < 3000) and partials_indexed:
             yield penalty, exp_count, dbf.lookup_by_names(name_tokens, addr_tokens)
index d1e542f572472ec60a6abd3be276d2094ed1458f..07767e48ad8934c5dc831c16e9c0040e9a3a6d01 100644 (file)
@@ -69,8 +69,8 @@ class DBConnection:
         self.current_params: Optional[Sequence[Any]] = None
         self.ignore_sql_errors = ignore_sql_errors
 
-        self.conn: Optional['psycopg2.connection'] = None
-        self.cursor: Optional['psycopg2.cursor'] = None
+        self.conn: Optional['psycopg2._psycopg.connection'] = None
+        self.cursor: Optional['psycopg2._psycopg.cursor'] = None
         self.connect(cursor_factory=cursor_factory)
 
     def close(self) -> None:
@@ -78,7 +78,7 @@ class DBConnection:
         """
         if self.conn is not None:
             if self.cursor is not None:
-                self.cursor.close() # type: ignore[no-untyped-call]
+                self.cursor.close()
                 self.cursor = None
             self.conn.close()
 
index 77d463d81d8e4dc0522bf1b2702aff0db66f21df..a64cbfaf99102ac0b24b56e609ad6462999b229e 100644 (file)
@@ -31,7 +31,7 @@ class Cursor(psycopg2.extras.DictCursor):
         """ Query execution that logs the SQL query when debugging is enabled.
         """
         if LOG.isEnabledFor(logging.DEBUG):
-            LOG.debug(self.mogrify(query, args).decode('utf-8')) # type: ignore[no-untyped-call]
+            LOG.debug(self.mogrify(query, args).decode('utf-8')) # type: ignore[arg-type]
 
         super().execute(query, args)
 
index 9a7b4f164787b8abb03831477fe3b876357e9b25..d9154ed90160b5b0a4c01e72fc6df5de4a9002cf 100644 (file)
@@ -118,4 +118,4 @@ class CopyBuffer:
         """
         if self.buffer.tell() > 0:
             self.buffer.seek(0)
-            cur.copy_from(self.buffer, table, columns=columns) # type: ignore[no-untyped-call]
+            cur.copy_from(self.buffer, table, columns=columns) # type: ignore[arg-type]