]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
dont stringify uq deferrable
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Feb 2025 14:09:51 +0000 (09:09 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Feb 2025 14:09:51 +0000 (09:09 -0500)
Fixed autogenerate rendering bug where the ``deferrable`` element of
``UniqueConstraint``, a bool, were being stringified rather than repr'ed
when generating Python code.

Fixes: #1613
Change-Id: I24bf7f3542566994559144c08cde2766d9ff4fe1

alembic/autogenerate/render.py
docs/build/unreleased/1613.rst [new file with mode: 0644]
tests/test_autogen_render.py

index b1e85f4b8c5683b62e78310596d78a0e96c538e9..50c51fa9304a13b038c24397c112efbec3167058 100644 (file)
@@ -634,9 +634,9 @@ def _uq_constraint(
     has_batch = autogen_context._has_batch
 
     if constraint.deferrable:
-        opts.append(("deferrable", str(constraint.deferrable)))
+        opts.append(("deferrable", constraint.deferrable))
     if constraint.initially:
-        opts.append(("initially", str(constraint.initially)))
+        opts.append(("initially", constraint.initially))
     if not has_batch and alter and constraint.table.schema:
         opts.append(("schema", _ident(constraint.table.schema)))
     if not alter and constraint.name:
diff --git a/docs/build/unreleased/1613.rst b/docs/build/unreleased/1613.rst
new file mode 100644 (file)
index 0000000..57126ba
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, autogenerate
+    :tickets: 1613
+
+    Fixed autogenerate rendering bug where the ``deferrable`` element of
+    ``UniqueConstraint``, a bool, were being stringified rather than repr'ed
+    when generating Python code.
index 06c0c84ea16fd96c90b557746871956529f96306..600e57834fdf07d89479c774228f21aad6af2544 100644 (file)
@@ -2437,11 +2437,11 @@ class RenderNamingConventionTest(TestBase):
         t = Table("t", self.metadata, Column("c", Integer))
         eq_ignore_whitespace(
             autogenerate.render._render_unique_constraint(
-                UniqueConstraint(t.c.c, deferrable="XYZ"),
+                UniqueConstraint(t.c.c, deferrable=True),
                 self.autogen_context,
                 None,
             ),
-            "sa.UniqueConstraint('c', deferrable='XYZ', "
+            "sa.UniqueConstraint('c', deferrable=True, "
             "name=op.f('uq_ct_t_c'))",
         )