]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Accommodate tuples for ColumnDefault.__repr__
authorNicolas CANIART <nicolas@caniart.net>
Tue, 31 Oct 2017 15:34:10 +0000 (11:34 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Oct 2017 15:40:00 +0000 (11:40 -0400)
Fixed bug where ``__repr__`` of :class:`.ColumnDefault` would fail
if the argument were a tuple.  Pull request courtesy Nicolas Caniart.

Change-Id: I08aa2448ef91054c43d6068ac54cedbdf7a83d64
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/1
Fixes: #4126
(cherry picked from commit 5acc9b149a4f7c44b8e7fbe926c0c5de8f13b2c4)

doc/build/changelog/unreleased_11/4126.rst [new file with mode: 0644]
lib/sqlalchemy/sql/schema.py
test/sql/test_metadata.py

diff --git a/doc/build/changelog/unreleased_11/4126.rst b/doc/build/changelog/unreleased_11/4126.rst
new file mode 100644 (file)
index 0000000..f269f1c
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, sql
+    :tickets: 4126
+    :versions: 1.2.0b4
+
+    Fixed bug where ``__repr__`` of :class:`.ColumnDefault` would fail
+    if the argument were a tuple.  Pull request courtesy Nicolas Caniart.
\ No newline at end of file
index 592dc390d310947dec8b1f55b5751b691e376a34..68baa80b664510db4fa1f55ddcf0746bb3db93f6 100644 (file)
@@ -2081,7 +2081,7 @@ class ColumnDefault(DefaultGenerator):
     __visit_name__ = property(_visit_name)
 
     def __repr__(self):
-        return "ColumnDefault(%r)" % self.arg
+        return "ColumnDefault(%r)" % (self.arg, )
 
 
 class Sequence(DefaultGenerator):
index 61fbbc57b46a95d1055c9458783de100fa04e259..5fac032fa5bb96583feeae73960e25ecb3b0b055 100644 (file)
@@ -550,6 +550,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables):
              "CheckConstraint("
              "%s"
              ", name='someconstraint')" % repr(ck.sqltext)),
+            (ColumnDefault(('foo', 'bar')), "ColumnDefault(('foo', 'bar'))")
         ):
             eq_(
                 repr(const),