]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Improve a few adaptation-related error messages
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 23 Nov 2021 20:23:47 +0000 (21:23 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 25 Nov 2021 15:35:31 +0000 (16:35 +0100)
psycopg/psycopg/_adapters_map.py
psycopg/psycopg/_queries.py
tests/types/test_shapely.py

index 4fe93c2822605c74fb6d217817f2725bc0ec6048..6908ecb4fca1dc599748fb90e212b14a32ab5935 100644 (file)
@@ -218,8 +218,8 @@ class AdaptersMap:
                 return d
 
         raise e.ProgrammingError(
-            f"cannot adapt type {cls.__name__}"
-            f" to format {PyFormat(format).name}"
+            f"cannot adapt type {cls.__name__!r} using placeholder '%{format}'"
+            f" (format: {PyFormat(format).name})"
         )
 
     def get_dumper_by_oid(self, oid: int, format: pq.Format) -> Type["Dumper"]:
index eeef76137531862a07ce1b198a432caa45f4dca9..b969da86c8e4852a75c0b4052493f2724e42e8d0 100644 (file)
@@ -268,8 +268,8 @@ def _split_query(query: bytes, encoding: str = "ascii") -> List[QueryPart]:
             )
         elif ph[-1:] not in b"sbt":
             raise e.ProgrammingError(
-                f"only '%s', '%b', '%t' placeholders allowed, got"
-                f" {m.group(0).decode(encoding)}"
+                f"only '%s', '%b', '%t' are allowed as placeholders, got"
+                f" '{m.group(0).decode(encoding)}'"
             )
 
         # Index or name
index 0ad2684a86694b2b8d9748bc89acd1e18566d65b..02bc210d27dba00a7b82f2201e1b3f485cbf98e8 100644 (file)
@@ -72,7 +72,7 @@ def shapely_conn(conn, svcconn):
 def test_no_adapter(conn):
     point = Point(1.2, 3.4)
     with pytest.raises(
-        psycopg.ProgrammingError, match="cannot adapt type Point"
+        psycopg.ProgrammingError, match="cannot adapt type 'Point'"
     ):
         conn.execute("SELECT pg_typeof(%s)", [point]).fetchone()[0]