From: Daniele Varrazzo Date: Fri, 6 Jan 2023 19:04:19 +0000 (+0000) Subject: docs: improve comment about why we need to register builtin numerics last X-Git-Tag: pool-3.2.0~70^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1aa47d5929bd457e8a15bdcb6ff0e0a1a60f0866;p=thirdparty%2Fpsycopg.git docs: improve comment about why we need to register builtin numerics last --- diff --git a/psycopg/psycopg/postgres.py b/psycopg/psycopg/postgres.py index 0b171f4d7..89e2e94e3 100644 --- a/psycopg/psycopg/postgres.py +++ b/psycopg/psycopg/postgres.py @@ -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)