From f9000e2a38bc879a4964a4f396e87185d0d21cd2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 23 Oct 2019 10:53:04 -0400 Subject: Use default repr() for quoted_name under python 3 Changed the ``repr()`` of the :class:`.quoted_name` construct to use regular string repr() under Python 3, rather than running it through "backslashreplace" escaping, which can be misleading. Modified the approach of "name normalization" for the Oracle and Firebird dialects, which converts from the UPPERCASE-as-case-insensitive convention of these dialects into lowercase-as-case-insensitive for SQLAlchemy, to not automatically apply the :class:`.quoted_name` construct to a name that matches itself under upper or lower case conversion, as is the case for many non-european characters. All names used within metadata structures are converted to :class:`.quoted_name` objects in any case; the change here would only affect the output of some inspection functions. Moved name normalize to be under default dialect, added test coverage in test/sql/test_quote.py Fixes: #4931 Change-Id: Ic121b20e07249824710a54423e321d94a425362f --- test/sql/test_unicode.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'test/sql/test_unicode.py') diff --git a/test/sql/test_unicode.py b/test/sql/test_unicode.py index 5b51644e6..dd7cad6b2 100644 --- a/test/sql/test_unicode.py +++ b/test/sql/test_unicode.py @@ -6,6 +6,7 @@ from sqlalchemy import ForeignKey from sqlalchemy import Integer from sqlalchemy import MetaData from sqlalchemy import testing +from sqlalchemy import util from sqlalchemy.testing import engines from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures @@ -190,14 +191,23 @@ class UnicodeSchemaTest(fixtures.TestBase): ue("\u6e2c\u8a66"), m, Column(ue("\u6e2c\u8a66_id"), Integer) ) - # I hardly understand what's going on with the backslashes in - # this one on py2k vs. py3k - eq_( - repr(t), - ( - "Table('\\u6e2c\\u8a66', MetaData(bind=None), " - "Column('\\u6e2c\\u8a66_id', Integer(), " - "table=<\u6e2c\u8a66>), " - "schema=None)" - ), - ) + if util.py2k: + eq_( + repr(t), + ( + "Table('\\u6e2c\\u8a66', MetaData(bind=None), " + "Column('\\u6e2c\\u8a66_id', Integer(), " + "table=<\u6e2c\u8a66>), " + "schema=None)" + ), + ) + else: + eq_( + repr(t), + ( + "Table('測試', MetaData(bind=None), " + "Column('測試_id', Integer(), " + "table=<測試>), " + "schema=None)" + ), + ) -- cgit v1.2.1