summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-04-09 09:16:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-04-09 17:40:14 -0400
commitc29b352d560120d9243010fd90fee88b0be745d7 (patch)
tree48f337e3608cd8f874cba7d5bf2187a1ca4a0448 /test/dialect/postgresql
parent1ec2f7cfd6c1fa8acf9a41330df597af99dcadc7 (diff)
downloadsqlalchemy-c29b352d560120d9243010fd90fee88b0be745d7.tar.gz
Propagate query-arg-only URL to psycopg2; don't send blank host
Fixed regression from release 1.3.2 caused by :ticket:`4562` where a URL that contained only a query string and no hostname, such as for the purposes of specifying a service file with connection information, would no longer be propagated to psycopg2 properly. The change in :ticket:`4562` has been adjusted to further suit psycopg2's exact requirements, which is that if there are any connection parameters whatsoever, the "dsn" parameter is no longer required, so in this case the query string parameters are passed alone. Fixes: #4601 Change-Id: Ic29a8b77bcf50ee996968bab25aaac7ae4bfc26f
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_dialect.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index 8c19e31bb..1a735c41d 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -129,6 +129,27 @@ class DialectTest(fixtures.TestBase):
eq_(cargs, [])
eq_(cparams, {"host": "host"})
+ def test_psycopg2_empty_connection_string_w_query_one(self):
+ dialect = psycopg2_dialect.dialect()
+ u = url.make_url("postgresql:///?service=swh-log")
+ cargs, cparams = dialect.create_connect_args(u)
+ eq_(cargs, [])
+ eq_(cparams, {"service": "swh-log"})
+
+ def test_psycopg2_empty_connection_string_w_query_two(self):
+ dialect = psycopg2_dialect.dialect()
+ u = url.make_url("postgresql:///?any_random_thing=yes")
+ cargs, cparams = dialect.create_connect_args(u)
+ eq_(cargs, [])
+ eq_(cparams, {"any_random_thing": "yes"})
+
+ def test_psycopg2_nonempty_connection_string_w_query(self):
+ dialect = psycopg2_dialect.dialect()
+ u = url.make_url("postgresql://somehost/?any_random_thing=yes")
+ cargs, cparams = dialect.create_connect_args(u)
+ eq_(cargs, [])
+ eq_(cparams, {"host": "somehost", "any_random_thing": "yes"})
+
class BatchInsertsTest(fixtures.TablesTest):
__only_on__ = "postgresql+psycopg2"