]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed a regression caused by :ticket:`2812` where the repr() for
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Nov 2013 18:16:49 +0000 (13:16 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 21 Nov 2013 18:16:49 +0000 (13:16 -0500)
table and column names would fail if the name contained non-ascii
characters. [ticket:2868]

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/sql/elements.py
test/sql/test_unicode.py

index 6081951ecbf28a4ad1ee42d78c26b94db4ba5ca1..ae6206b2fd43419e33230d805df846d2eea4641f 100644 (file)
 .. changelog::
     :version: 0.9.0b2
 
+    .. change::
+        :tags: bug, schema
+        :tickets: 2868
+
+        Fixed a regression caused by :ticket:`2812` where the repr() for
+        table and column names would fail if the name contained non-ascii
+        characters.
+
     .. change::
         :tags: bug, engine
         :tickets: 2848
index 5058b90e02126280a16621aca158960ebfb7e799..1854588141f7f48f87d4eff057fd2d2b1c985183 100644 (file)
@@ -2355,7 +2355,7 @@ class quoted_name(util.text_type):
             return util.text_type(self).upper()
 
     def __repr__(self):
-        return "'%s'" % self
+        return util.text_type.__repr__(self)
 
 class _truncated_label(quoted_name):
     """A unicode subclass used to identify symbolic "
index ffcef903f3be847f2e48d0e63bec402cf52247e3..454bc8f57bf01c28dcd37f51b27b508e3dda2545 100644 (file)
@@ -2,7 +2,7 @@
 """verrrrry basic unicode column name testing"""
 
 from sqlalchemy import *
-from sqlalchemy.testing import fixtures, engines
+from sqlalchemy.testing import fixtures, engines, eq_
 from sqlalchemy import testing
 from sqlalchemy.testing.engines import utf8_engine
 from sqlalchemy.sql import column
@@ -114,6 +114,18 @@ class UnicodeSchemaTest(fixtures.TestBase):
         meta.drop_all()
         metadata.create_all()
 
+    def test_repr(self):
+
+        m = MetaData()
+        t = Table(ue('\u6e2c\u8a66'), m, Column(ue('\u6e2c\u8a66_id'), Integer))
+
+        eq_(
+            repr(t),
+            (
+                "Table(u'\\u6e2c\\u8a66', MetaData(bind=None), "
+                "Column(u'\\u6e2c\\u8a66_id', Integer(), table=<\\u6e2c\\u8a66>), "
+                "schema=None)"))
+
 class EscapesDefaultsTest(fixtures.TestBase):
     def test_default_exec(self):
         metadata = MetaData(testing.db)