Skip to content

Commit 36231bc

Browse files
committed
dont stringify uq deferrable
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
1 parent 4ecf4ad commit 36231bc

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

alembic/autogenerate/render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,9 @@ def _uq_constraint(
634634
has_batch = autogen_context._has_batch
635635

636636
if constraint.deferrable:
637-
opts.append(("deferrable", str(constraint.deferrable)))
637+
opts.append(("deferrable", constraint.deferrable))
638638
if constraint.initially:
639-
opts.append(("initially", str(constraint.initially)))
639+
opts.append(("initially", constraint.initially))
640640
if not has_batch and alter and constraint.table.schema:
641641
opts.append(("schema", _ident(constraint.table.schema)))
642642
if not alter and constraint.name:

docs/build/unreleased/1613.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. change::
2+
:tags: bug, autogenerate
3+
:tickets: 1613
4+
5+
Fixed autogenerate rendering bug where the ``deferrable`` element of
6+
``UniqueConstraint``, a bool, were being stringified rather than repr'ed
7+
when generating Python code.

tests/test_autogen_render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,11 +2437,11 @@ def test_explicit_unique_constraint(self):
24372437
t = Table("t", self.metadata, Column("c", Integer))
24382438
eq_ignore_whitespace(
24392439
autogenerate.render._render_unique_constraint(
2440-
UniqueConstraint(t.c.c, deferrable="XYZ"),
2440+
UniqueConstraint(t.c.c, deferrable=True),
24412441
self.autogen_context,
24422442
None,
24432443
),
2444-
"sa.UniqueConstraint('c', deferrable='XYZ', "
2444+
"sa.UniqueConstraint('c', deferrable=True, "
24452445
"name=op.f('uq_ct_t_c'))",
24462446
)
24472447

0 commit comments

Comments
 (0)