summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-10-23 10:53:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-24 10:13:27 -0400
commitf9000e2a38bc879a4964a4f396e87185d0d21cd2 (patch)
treeb6925ca5a92e5b9009288bdb048040af463dad8e /lib/sqlalchemy/dialects
parentd76cb7213557c24609a1a75d8c391aea0179562a (diff)
downloadsqlalchemy-f9000e2a38bc879a4964a4f396e87185d0d21cd2.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py26
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py30
2 files changed, 0 insertions, 56 deletions
diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py
index a852c7824..c7c921cb4 100644
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -86,7 +86,6 @@ from sqlalchemy.engine import default
from sqlalchemy.engine import reflection
from sqlalchemy.sql import compiler
from sqlalchemy.sql import expression
-from sqlalchemy.sql.elements import quoted_name
from sqlalchemy.types import BIGINT
from sqlalchemy.types import BLOB
from sqlalchemy.types import DATE
@@ -659,31 +658,6 @@ class FBDialect(default.DefaultDialect):
"implicit_returning", True
)
- def normalize_name(self, name):
- # Remove trailing spaces: FB uses a CHAR() type,
- # that is padded with spaces
- name = name and name.rstrip()
- if name is None:
- return None
- elif name.upper() == name and not (
- self.identifier_preparer._requires_quotes
- )(name.lower()):
- return name.lower()
- elif name.lower() == name:
- return quoted_name(name, quote=True)
- else:
- return name
-
- def denormalize_name(self, name):
- if name is None:
- return None
- elif name.lower() == name and not (
- self.identifier_preparer._requires_quotes
- )(name.lower()):
- return name.upper()
- else:
- return name
-
def has_table(self, connection, table_name, schema=None):
"""Return ``True`` if the given table exists, ignoring
the `schema`."""
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 48b90f7e9..4c5a717b9 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -457,7 +457,6 @@ from ...sql import compiler
from ...sql import expression
from ...sql import util as sql_util
from ...sql import visitors
-from ...sql.elements import quoted_name
from ...types import BLOB
from ...types import CHAR
from ...types import CLOB
@@ -1388,35 +1387,6 @@ class OracleDialect(default.DefaultDialect):
)
return cursor.first() is not None
- def normalize_name(self, name):
- if name is None:
- return None
- if util.py2k:
- if isinstance(name, str):
- name = name.decode(self.encoding)
- if name.upper() == name and not (
- self.identifier_preparer._requires_quotes
- )(name.lower()):
- return name.lower()
- elif name.lower() == name:
- return quoted_name(name, quote=True)
- else:
- return name
-
- def denormalize_name(self, name):
- if name is None:
- return None
- elif name.lower() == name and not (
- self.identifier_preparer._requires_quotes
- )(name.lower()):
- name = name.upper()
- if util.py2k:
- if not self.supports_unicode_binds:
- name = name.encode(self.encoding)
- else:
- name = unicode(name) # noqa
- return name
-
def _get_default_schema_name(self, connection):
return self.normalize_name(
connection.execute("SELECT USER FROM DUAL").scalar()