]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
docs: improve comment about why we need to register builtin numerics last
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 6 Jan 2023 19:04:19 +0000 (19:04 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 5 Aug 2023 14:21:30 +0000 (15:21 +0100)
psycopg/psycopg/postgres.py

index 0b171f4d7fe14f31e733d61407cc49a90245cb48..89e2e94e35f860da5ed1e352e2b31981a4f01fef 100644 (file)
@@ -120,8 +120,11 @@ def register_default_adapters(context: AdaptContext) -> None:
     string.register_default_adapters(context)
     uuid.register_default_adapters(context)
 
-    # Make sure to register dumpers to the standard types last, in order to
-    # pick them by default when looking up by oid.
+    # Both numpy Decimal and uint64 dumpers use the numeric oid, but the former
+    # covers the entire numeric domain, whereas the latter only deals with
+    # integers. For this reason, if we specify dumpers by oid, we want to make
+    # sure to get the Decimal dumper. We enforce that by registering the
+    # numeric dumpers last.
     numpy.register_default_adapters(context)
     bool.register_default_adapters(context)
     numeric.register_default_adapters(context)