From: Mike Bayer Date: Thu, 21 Nov 2013 18:16:49 +0000 (-0500) Subject: - Fixed a regression caused by :ticket:`2812` where the repr() for X-Git-Tag: rel_0_9_0~112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=42fd77a4bfb8c5a1c02c89a17481a90cd039f10e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed a regression caused by :ticket:`2812` where the repr() for table and column names would fail if the name contained non-ascii characters. [ticket:2868] --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 6081951ecb..ae6206b2fd 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,14 @@ .. 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 diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 5058b90e02..1854588141 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -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 " diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py index ffcef903f3..454bc8f57b 100644 --- a/test/sql/test_unicode.py +++ b/test/sql/test_unicode.py @@ -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)