From 42fd77a4bfb8c5a1c02c89a17481a90cd039f10e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 21 Nov 2013 13:16:49 -0500 Subject: [PATCH] - 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] --- doc/build/changelog/changelog_09.rst | 8 ++++++++ lib/sqlalchemy/sql/elements.py | 2 +- test/sql/test_unicode.py | 14 +++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) 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) -- 2.47.3