From 3eee887232137188ece8204d23ab00d4ba4b2ce4 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Sun, 28 Feb 2010 23:56:11 +0000 Subject: [PATCH] Changes to get mysqlconnector passing most tests. --- lib/sqlalchemy/dialects/mysql/base.py | 8 ++++++++ lib/sqlalchemy/dialects/mysql/mysqlconnector.py | 5 ++--- test/engine/test_execute.py | 4 ++-- test/orm/test_naturalpks.py | 8 ++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index b9e3080b28..2311b06df1 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -2504,7 +2504,11 @@ class _DecodingRowProxy(object): item = self.rowproxy[index] if isinstance(item, _array): item = item.tostring() + # Py2K if self.charset and isinstance(item, str): + # end Py2K + # Py3K + #if self.charset and isinstance(item, bytes): return item.decode(self.charset) else: return item @@ -2513,7 +2517,11 @@ class _DecodingRowProxy(object): item = getattr(self.rowproxy, attr) if isinstance(item, _array): item = item.tostring() + # Py2K if self.charset and isinstance(item, str): + # end Py2K + # Py3K + #if self.charset and isinstance(item, bytes): return item.decode(self.charset) else: return item diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index f715b72dff..9e7caae565 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -49,11 +49,10 @@ class _myconnpyBIT(BIT): class MySQL_mysqlconnector(MySQLDialect): driver = 'mysqlconnector' - supports_unicode_statements = False + supports_unicode_statements = True supports_unicode_binds = True - supports_sane_rowcount = False + supports_sane_rowcount = True supports_sane_multi_rowcount = True - description_encoding = None default_paramstyle = 'format' execution_ctx_cls = MySQL_mysqlconnectorExecutionContext diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 1752fda0dd..4004ae9366 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -50,7 +50,7 @@ class ExecuteTest(TestBase): (7, 'sally')] conn.execute("delete from users") - @testing.fails_on_everything_except('mysql+mysqldb', 'postgresql') + @testing.fails_on_everything_except('mysql+mysqldb', 'mysql+mysqlconnector', 'postgresql') @testing.fails_on('postgresql+zxjdbc', 'sprintf not supported') # some psycopg2 versions bomb this. def test_raw_sprintf(self): @@ -70,7 +70,7 @@ class ExecuteTest(TestBase): # pyformat is supported for mysql, but skipping because a few driver # versions have a bug that bombs out on this test. (1.2.2b3, 1.2.2c1, 1.2.2) @testing.skip_if(lambda: testing.against('mysql+mysqldb'), 'db-api flaky') - @testing.fails_on_everything_except('postgresql+psycopg2', 'postgresql+pypostgresql') + @testing.fails_on_everything_except('postgresql+psycopg2', 'postgresql+pypostgresql', 'mysql+mysqlconnector') def test_raw_python(self): for conn in (testing.db, testing.db.connect()): conn.execute("insert into users (user_id, user_name) values (%(id)s, %(name)s)", diff --git a/test/orm/test_naturalpks.py b/test/orm/test_naturalpks.py index b061766bf3..70adb1a8bc 100644 --- a/test/orm/test_naturalpks.py +++ b/test/orm/test_naturalpks.py @@ -594,7 +594,7 @@ class CascadeToFKPKTest(_base.MappedTest, testing.AssertsCompiledSQL): self._test_onetomany(True) # PG etc. need passive=True to allow PK->PK cascade - @testing.fails_on_everything_except('sqlite') + @testing.fails_on_everything_except('sqlite', 'mysql+mysqlconnector') def test_onetomany_nonpassive(self): self._test_onetomany(False) @@ -737,7 +737,7 @@ class JoinedInheritanceTest(_base.MappedTest): self._test_pk(True) # PG etc. need passive=True to allow PK->PK cascade - @testing.fails_on_everything_except('sqlite') + @testing.fails_on_everything_except('sqlite', 'mysql+mysqlconnector') def test_pk_nonpassive(self): self._test_pk(False) @@ -747,7 +747,7 @@ class JoinedInheritanceTest(_base.MappedTest): self._test_fk(True) # PG etc. need passive=True to allow PK->PK cascade - @testing.fails_on_everything_except('sqlite') + @testing.fails_on_everything_except('sqlite', 'mysql+mysqlconnector') def test_fk_nonpassive(self): self._test_fk(False) @@ -803,4 +803,4 @@ class JoinedInheritanceTest(_base.MappedTest): - \ No newline at end of file + -- 2.47.3