]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
repair psycopg2 (and psycopg) multiple hosts format
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 1 Aug 2022 14:29:13 +0000 (10:29 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 1 Aug 2022 19:21:04 +0000 (15:21 -0400)
commitddc326585a5a40d5c5e18444b14022e78751cdbb
tree08ca4205f3197a8b393eb1fac62d7bf43c3144d6
parent3ff18812d8d80b2016ceeea98c808a76cae85e48
repair psycopg2 (and psycopg) multiple hosts format

Fixed issue in psycopg2 dialect where the "multiple hosts" feature
implemented for :ticket:`4392`, where multiple ``host:port`` pairs could be
passed in the query string as
``?host=host1:port1&host=host2:port2&host=host3:port3`` was not implemented
correctly, as it did not propagate the "port" parameter appropriately.
Connections that didn't use a different "port" likely worked without issue,
and connections that had "port" for some of the entries may have
incorrectly passed on that hostname. The format is now corrected to pass
hosts/ports appropriately.

As part of this change, maintained support for another multihost style that
worked unintentionally, which is comma-separated
``?host=h1,h2,h3&port=p1,p2,p3``. This format is more consistent with
libpq's query-string format, whereas the previous format is inspired by a
different aspect of libpq's URI format but is not quite the same thing.

If the two styles are mixed together, an error is raised as this is
ambiguous.

Fixes: #4392
Change-Id: Ic9cc0b0e6e90725e158d9efe73e042853dd1263f
doc/build/changelog/unreleased_14/4392.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/_psycopg_common.py
lib/sqlalchemy/dialects/postgresql/psycopg.py
lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/postgresql/test_dialect.py