From: Mike Bayer Date: Thu, 27 Mar 2014 23:18:06 +0000 (-0400) Subject: - Tweaked the settings for mysql-connector-python; in Py2K, the X-Git-Tag: rel_0_9_4~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=50576a01eb39742632268fe1e595a554625171eb;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Tweaked the settings for mysql-connector-python; in Py2K, the "supports unicode statements" flag is now False, so that SQLAlchemy will encode the *SQL string* (note: *not* the parameters) to bytes before sending to the database. This seems to allow all unicode-related tests to pass for mysql-connector, including those that use non-ascii table/column names, as well as some tests for the TEXT type using unicode under cursor.executemany(). - other mysql-connector fixes; latest version seems to do better on function call counts --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index de24d35aa0..f16dd4f89a 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,17 @@ .. changelog:: :version: 0.9.4 + .. change:: + :tags: bug, mysql + + Tweaked the settings for mysql-connector-python; in Py2K, the + "supports unicode statements" flag is now False, so that SQLAlchemy + will encode the *SQL string* (note: *not* the parameters) + to bytes before sending to the database. This seems to allow + all unicode-related tests to pass for mysql-connector, including those + that use non-ascii table/column names, as well as some tests for the + TEXT type using unicode under cursor.executemany(). + .. change:: :tags: feature, engine diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index 408bc41dd2..3536c3ad81 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -52,8 +52,11 @@ class _myconnpyBIT(BIT): class MySQLDialect_mysqlconnector(MySQLDialect): driver = 'mysqlconnector' - supports_unicode_statements = True + + if util.py2k: + supports_unicode_statements = False supports_unicode_binds = True + supports_sane_rowcount = True supports_sane_multi_rowcount = True diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 7b2d0f40ae..76e48f8c87 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -366,6 +366,13 @@ class SuiteRequirements(Requirements): return exclusions.open() + @property + def date_coerces_from_datetime(self): + """target dialect accepts a datetime object as the target + of a date column.""" + + return exclusions.open() + @property def date_historic(self): """target dialect supports representation of Python diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 7e2ef8ab8b..5d8005f4bd 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -299,7 +299,7 @@ class DateTest(_DateFixture, fixtures.TablesTest): class DateTimeCoercedToDateTimeTest(_DateFixture, fixtures.TablesTest): - __requires__ = 'date', + __requires__ = 'date', 'date_coerces_from_datetime' __backend__ = True datatype = Date data = datetime.datetime(2012, 10, 15, 12, 57, 18) diff --git a/setup.cfg b/setup.cfg index e929c17e4b..d00c2fffff 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,7 @@ postgresql=postgresql://scott:tiger@127.0.0.1:5432/test postgres=postgresql://scott:tiger@127.0.0.1:5432/test postgresql_jython=postgresql+zxjdbc://scott:tiger@127.0.0.1:5432/test mysql=mysql://scott:tiger@127.0.0.1:3306/test +mysqlconnector=mysql+mysqlconnector://scott:tiger@127.0.0.1:3306/test mssql=mssql+pyodbc://scott:tiger@ms_2005 oursql=mysql+oursql://scott:tiger@127.0.0.1:3306/test pymysql=mysql+pymysql://scott:tiger@127.0.0.1:3306/test?charset=utf8 diff --git a/test/profiles.txt b/test/profiles.txt index de5b65e84e..439c2abf59 100644 --- a/test/profiles.txt +++ b/test/profiles.txt @@ -167,7 +167,7 @@ test.aaa_profiling.test_orm.AttributeOverheadTest.test_collection_append_remove # TEST: test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline -test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline 2.7_mysql_mysqlconnector_cextensions 111739 +test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline 2.7_mysql_mysqlconnector_cextensions 100535 test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline 2.7_mysql_mysqlconnector_nocextensions 120756 test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline 2.7_mysql_mysqldb_cextensions 30052 test.aaa_profiling.test_orm.DeferOptionsTest.test_baseline 2.7_mysql_mysqldb_nocextensions 39069 @@ -272,7 +272,7 @@ test.aaa_profiling.test_orm.MergeBackrefsTest.test_merge_pending_with_all_pks 3. # TEST: test.aaa_profiling.test_orm.MergeTest.test_merge_load test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.6_sqlite_pysqlite_nocextensions 1521 -test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.7_mysql_mysqlconnector_cextensions 2453 +test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.7_mysql_mysqlconnector_cextensions 2271 test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.7_mysql_mysqlconnector_nocextensions 2478 test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.7_mysql_mysqldb_cextensions 1388 test.aaa_profiling.test_orm.MergeTest.test_merge_load 2.7_mysql_mysqldb_nocextensions 1413 @@ -467,7 +467,7 @@ test.aaa_profiling.test_resultset.ResultSetTest.test_contains_doesnt_compile 3.4 # TEST: test.aaa_profiling.test_resultset.ResultSetTest.test_string test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.6_sqlite_pysqlite_nocextensions 15447 -test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqlconnector_cextensions 110262 +test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqlconnector_cextensions 92960 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqlconnector_nocextensions 125282 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqldb_cextensions 512 test.aaa_profiling.test_resultset.ResultSetTest.test_string 2.7_mysql_mysqldb_nocextensions 15505 @@ -494,7 +494,7 @@ test.aaa_profiling.test_resultset.ResultSetTest.test_string 3.4_sqlite_pysqlite_ # TEST: test.aaa_profiling.test_resultset.ResultSetTest.test_unicode test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.6_sqlite_pysqlite_nocextensions 15447 -test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqlconnector_cextensions 110262 +test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqlconnector_cextensions 92960 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqlconnector_nocextensions 125282 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqldb_cextensions 512 test.aaa_profiling.test_resultset.ResultSetTest.test_unicode 2.7_mysql_mysqldb_nocextensions 45505 diff --git a/test/requirements.py b/test/requirements.py index d04c1a0aa2..4184058b2d 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -13,6 +13,7 @@ from sqlalchemy.testing.exclusions import \ only_if,\ only_on,\ fails_on_everything_except,\ + fails_on,\ fails_if,\ succeeds_if,\ SpecPredicate,\ @@ -399,11 +400,6 @@ class DefaultRequirements(SuiteRequirements): no_support('sybase', 'FIXME: guessing, needs confirmation'), no_support('mssql+pymssql', 'no FreeTDS support'), - LambdaPredicate( - lambda config: (not util.py3k and against(config, "mysql+mysqlconnector")), - "mysqlconnector seems to handle heavy unicode only in py3k" - ), - exclude('mysql', '<', (4, 1, 1), 'no unicode connection support'), ]) @@ -437,9 +433,8 @@ class DefaultRequirements(SuiteRequirements): """ return skip_if('mssql+pymssql', 'crashes on pymssql') + \ - fails_on_everything_except('mysql+mysqldb', 'mysql+oursql', - 'sqlite+pysqlite', 'mysql+pymysql', - 'mysql+cymysql') + fails_on_everything_except('mysql', + 'sqlite+pysqlite') @property def sane_multi_rowcount(self): @@ -498,6 +493,13 @@ class DefaultRequirements(SuiteRequirements): return exclusions.open() + @property + def date_coerces_from_datetime(self): + """target dialect accepts a datetime object as the target + of a date column.""" + + return fails_on('mysql+mysqlconnector') + @property def date_historic(self): """target dialect supports representation of Python