]> 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:25:12 +0000 (15:25 -0400)
commit011e5f87138a29c2b4555bf494cee16c804e1e45
tree367e0c01205df00a9e8883abfe74ac8a2547a3d4
parentcde43899d6c872f6d58354f7324f707b9c8bcd8e
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
(cherry picked from commit 93e6f4f05ba885b16accf0ad811160dd7d0eec70)
doc/build/changelog/unreleased_14/4392.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/psycopg2.py
test/dialect/postgresql/test_dialect.py