summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-11-07 15:47:15 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-11-10 11:24:53 -0500
commitbd2a6e9b161251606b64d299faec583d55c2e802 (patch)
treecb9e304b72be61c59709caa792920515afc26c32 /test/dialect
parent0c6071513fea9d183dc67979a239dff746992571 (diff)
downloadsqlalchemy-bd2a6e9b161251606b64d299faec583d55c2e802.tar.gz
removals: all unicode encoding / decoding
Removed here includes: * convert_unicode parameters * encoding create_engine() parameter * description encoding support * "non-unicode fallback" modes under Python 2 * String symbols regarding Python 2 non-unicode fallbacks * any concept of DBAPIs that don't accept unicode statements, unicode bound parameters, or that return bytes for strings anywhere except an explicit Binary / BLOB type * unicode processors in Python / C Risk factors: * Whether all DBAPIs do in fact return Unicode objects for all entries in cursor.description now * There was logic for mysql-connector trying to determine description encoding. A quick test shows Unicode coming back but it's not clear if there are still edge cases where they return bytes. if so, these are bugs in that driver, and at most we would only work around it in the mysql-connector DBAPI itself (but we won't do that either). * It seems like Oracle 8 was not expecting unicode bound parameters. I'm assuming this was all Python 2 stuff and does not apply for modern cx_Oracle under Python 3. * third party dialects relying upon built in unicode encoding/decoding but it's hard to imagine any non-SQLAlchemy database driver not dealing exclusively in Python unicode strings in Python 3 Change-Id: I97d762ef6d4dd836487b714d57d8136d0310f28a References: #7257
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/mssql/test_reflection.py7
-rw-r--r--test/dialect/oracle/test_dialect.py31
-rw-r--r--test/dialect/oracle/test_types.py12
-rw-r--r--test/dialect/postgresql/test_dialect.py8
-rw-r--r--test/dialect/postgresql/test_types.py5
5 files changed, 17 insertions, 46 deletions
diff --git a/test/dialect/mssql/test_reflection.py b/test/dialect/mssql/test_reflection.py
index 01c5e845e..1789166ee 100644
--- a/test/dialect/mssql/test_reflection.py
+++ b/test/dialect/mssql/test_reflection.py
@@ -22,7 +22,6 @@ from sqlalchemy import types as sqltypes
from sqlalchemy import util
from sqlalchemy.dialects import mssql
from sqlalchemy.dialects.mssql import base
-from sqlalchemy.dialects.mssql.information_schema import CoerceUnicode
from sqlalchemy.dialects.mssql.information_schema import tables
from sqlalchemy.schema import CreateIndex
from sqlalchemy.testing import AssertsCompiledSQL
@@ -550,12 +549,6 @@ class ReflectionTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL):
class InfoCoerceUnicodeTest(fixtures.TestBase, AssertsCompiledSQL):
- def test_info_unicode_coercion(self):
-
- dialect = mssql.dialect()
- value = CoerceUnicode().bind_processor(dialect)("a string")
- assert isinstance(value, util.text_type)
-
def test_info_unicode_cast_no_2000(self):
dialect = mssql.dialect()
dialect.server_version_info = base.MS_2000_VERSION
diff --git a/test/dialect/oracle/test_dialect.py b/test/dialect/oracle/test_dialect.py
index f287a9a0b..ccf771f81 100644
--- a/test/dialect/oracle/test_dialect.py
+++ b/test/dialect/oracle/test_dialect.py
@@ -259,22 +259,15 @@ class EncodingErrorsTest(fixtures.TestBase):
def test_older_cx_oracle_warning(self, cx_Oracle, cx_oracle_type):
cx_Oracle.version = "6.3"
- ignore_dialect = cx_oracle.dialect(
- dbapi=cx_Oracle, encoding_errors="ignore"
- )
- ignore_outputhandler = (
- ignore_dialect._generate_connection_outputtype_handler()
- )
-
- cursor = mock.Mock()
-
with testing.expect_warnings(
r"cx_oracle version \(6, 3\) does not support encodingErrors"
):
- ignore_outputhandler(
- cursor, "foo", cx_oracle_type, None, None, None
+ dialect = cx_oracle.dialect(
+ dbapi=cx_Oracle, encoding_errors="ignore"
)
+ eq_(dialect._cursor_var_unicode_kwargs, {})
+
@_oracle_char_combinations
def test_encoding_errors_cx_oracle(
self,
@@ -319,10 +312,18 @@ class EncodingErrorsTest(fixtures.TestBase):
cursor = mock.Mock()
plain_outputhandler(cursor, "foo", cx_oracle_type, None, None, None)
- eq_(
- cursor.mock_calls,
- [mock.call.var(mock.ANY, None, cursor.arraysize)],
- )
+ if cx_oracle_type in (cx_Oracle.FIXED_CHAR, cx_Oracle.STRING):
+ # no calls; without encodingErrors, use cx_Oracle's default unicode
+ # handling
+ eq_(
+ cursor.mock_calls,
+ [],
+ )
+ else:
+ eq_(
+ cursor.mock_calls,
+ [mock.call.var(mock.ANY, None, cursor.arraysize)],
+ )
class ComputedReturningTest(fixtures.TablesTest):
diff --git a/test/dialect/oracle/test_types.py b/test/dialect/oracle/test_types.py
index 2b54f2b56..cbbb7be7c 100644
--- a/test/dialect/oracle/test_types.py
+++ b/test/dialect/oracle/test_types.py
@@ -714,18 +714,6 @@ class TypesTest(fixtures.TestBase):
eq_(sqla_result, cx_oracle_result)
- def test_coerce_to_unicode(self, connection):
- engine = testing_engine(options=dict(coerce_to_unicode=False))
- with engine.connect() as conn_no_coerce:
- value = exec_sql(
- conn_no_coerce, "SELECT 'hello' FROM DUAL"
- ).scalar()
- assert not isinstance(value, util.binary_type)
- assert isinstance(value, util.text_type)
-
- value = exec_sql(connection, "SELECT 'hello' FROM DUAL").scalar()
- assert isinstance(value, util.text_type)
-
def test_reflect_dates(self, metadata, connection):
Table(
"date_types",
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index fe3700bbb..c12f4a50a 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -161,14 +161,6 @@ $$ LANGUAGE plpgsql;"""
future_connection.dialect.server_version_info,
)
- @testing.requires.psycopg2_compatibility
- def test_pg_dialect_no_native_unicode_in(self, testing_engine):
- with testing.expect_raises_message(
- exc.ArgumentError,
- "psycopg2 native_unicode mode is required under Python 3",
- ):
- testing_engine(options=dict(use_native_unicode=False))
-
def test_psycopg2_empty_connection_string(self):
dialect = psycopg2_dialect.dialect()
u = url.make_url("postgresql+psycopg2://")
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index ebb4d4b12..96601d6ad 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -3826,10 +3826,7 @@ class JSONRoundTripTest(fixtures.TablesTest):
result = connection.execute(
select(data_table.c.data["k1"].astext)
).first()
- if connection.dialect.returns_unicode_strings:
- assert isinstance(result[0], util.text_type)
- else:
- assert isinstance(result[0], util.string_types)
+ assert isinstance(result[0], util.text_type)
def test_query_returned_as_int(self, connection):
self._fixture_data(connection)