]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug in `URL.normalized_query`
authorFederico Caselli <cfederico87@gmail.com>
Fri, 21 Apr 2023 20:26:11 +0000 (22:26 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 25 Apr 2023 16:52:08 +0000 (18:52 +0200)
Fixed a bug that prevented use of :attr:`_engine.URL.normalized_query` in
SQLAlchemy v2.

Fixes: #9682
Change-Id: I2704154af34f438b4cbb290602fc936c1184c074

doc/build/changelog/unreleased_20/9682.rst [new file with mode: 0644]
lib/sqlalchemy/engine/url.py
test/engine/test_parseconnect.py

diff --git a/doc/build/changelog/unreleased_20/9682.rst b/doc/build/changelog/unreleased_20/9682.rst
new file mode 100644 (file)
index 0000000..bfd4b06
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug, engine
+    :tickets: 9682
+
+    Fixed a bug that prevented use of :attr:`_engine.URL.normalized_query` in
+    SQLAlchemy v2.
index ea1e926e62ff583c13319fa4bb69638c0a001f25..0315737d660a2cd3f7e4663eadfd9ba752f8aff9 100644 (file)
@@ -564,7 +564,7 @@ class URL(NamedTuple):
             ),
         )
 
-    @util.memoized_property
+    @property
     def normalized_query(self) -> Mapping[str, Sequence[str]]:
         """Return the :attr:`_engine.URL.query` dictionary with values normalized
         into sequences.
index 471201666d847a859c610509f327616430cb3814..65cf6b5f1f7c4b530e8d947872867268970ea871 100644 (file)
@@ -179,6 +179,7 @@ class URLTest(fixtures.TestBase):
     def test_query_string(self):
         u = url.make_url("dialect://user:pass@host/db?arg1=param1&arg2=param2")
         eq_(u.query, {"arg1": "param1", "arg2": "param2"})
+        eq_(u.normalized_query, {"arg1": ("param1",), "arg2": ("param2",)})
         eq_(
             u.render_as_string(hide_password=False),
             "dialect://user:pass@host/db?arg1=param1&arg2=param2",
@@ -214,6 +215,10 @@ class URLTest(fixtures.TestBase):
             "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3"
         )
         eq_(u.query, {"arg1": "param1", "arg2": ("param2", "param3")})
+        eq_(
+            u.normalized_query,
+            {"arg1": ("param1",), "arg2": ("param2", "param3")},
+        )
         eq_(
             u.render_as_string(hide_password=False),
             "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3",
@@ -222,6 +227,7 @@ class URLTest(fixtures.TestBase):
         test_url = "dialect://user:pass@host/db?arg1%3D=param1&arg2=param+2"
         u = url.make_url(test_url)
         eq_(u.query, {"arg1=": "param1", "arg2": "param 2"})
+        eq_(u.normalized_query, {"arg1=": ("param1",), "arg2": ("param 2",)})
         eq_(u.render_as_string(hide_password=False), test_url)
 
     def test_comparison(self):