]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
add option to disable INET, CIDR result set conversion
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 3 Jul 2023 17:28:35 +0000 (13:28 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Jul 2023 18:12:29 +0000 (14:12 -0400)
commit5d709b53685d049b8c8d7a57e5319d5babcf807a
treee51b574010b05aada82cdbd4bd4aefc77dd05cdb
parent3d89eb1bdcda2757f014bffde5881da3ce5c7463
add option to disable INET, CIDR result set conversion

Added new parameter ``native_inet_types=False`` to the all PostgreSQL
dialects, which indicates the all converters used by the DBAPI to
convert rows from PostgreSQL :class:`.INET` and :class:`.CIDR` columns
into Python ``ipaddress`` datatypes should be disabled, returning strings
instead.  This allows code written to work with strings for these datatypes
to be migrated to asyncpg, psycopg, or pg8000 without code changes
beyond the engine parameter.

Currently, some DBAPIs return ``ipaddress`` objects while others return
strings for one or both of these datatypes.   A future release of
SQLAlchemy will attempt to normalize support for Python's ``ipaddress``
across all DBAPIs.

Fixes: #9945
Change-Id: Id59e9982e2bfd6706fe335e4e700902abfb63663
doc/build/changelog/unreleased_20/9945.rst [new file with mode: 0644]
doc/build/dialects/postgresql.rst
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/dialects/postgresql/pg8000.py
lib/sqlalchemy/dialects/postgresql/psycopg.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/postgresql/test_types.py