]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
use new URL api for password obfuscate
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Mar 2021 13:40:27 +0000 (09:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 Mar 2021 13:40:27 +0000 (09:40 -0400)
Fixed regression caused by SQLAlchemy 1.4 where the "alembic current"
command would fail due to changes in the ``URL`` object.

Change-Id: Ic0023885188c75ace19035adcf4c11c7bd10a843
Fixes: #816
alembic/util/messaging.py
docs/build/unreleased/816.rst [new file with mode: 0644]
tests/test_command.py

index 38a3f13e006abee60e15466da84e900666e1d28b..29442d8135b61f97e3262b258673cff21e7f8f71 100644 (file)
@@ -5,6 +5,7 @@ import warnings
 
 from sqlalchemy.engine import url
 
+from . import sqla_compat
 from .compat import binary_type
 from .compat import collections_abc
 from .compat import string_types
@@ -64,7 +65,10 @@ def err(message):
 def obfuscate_url_pw(u):
     u = url.make_url(u)
     if u.password:
-        u.password = "XXXXX"
+        if sqla_compat.sqla_14:
+            u = u.set(password="XXXXX")
+        else:
+            u.password = "XXXXX"
     return str(u)
 
 
diff --git a/docs/build/unreleased/816.rst b/docs/build/unreleased/816.rst
new file mode 100644 (file)
index 0000000..9ce2425
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, environment
+    :tickets: 816
+
+    Fixed regression caused by SQLAlchemy 1.4 where the "alembic current"
+    command would fail due to changes in the ``URL`` object.
+
index 8350e829a58041cd27da0f619b950ef312aa1fac..6fb99579865ea46e83ecdfb396c54691d7951a30 100644 (file)
@@ -252,6 +252,12 @@ class CurrentTest(_BufMixin, TestBase):
         with self._assert_lines(["a3"]):
             command.current(self.cfg)
 
+    def test_current_obfuscate_password(self):
+        eq_(
+            util.obfuscate_url_pw("postgresql://scott:tiger@localhost/test"),
+            "postgresql://scott:XXXXX@localhost/test",
+        )
+
     def test_two_heads(self):
         command.stamp(self.cfg, ())
         command.stamp(self.cfg, (self.a1.revision, self.b1.revision))