From 2b85e80d75f58a7691533a44693378e28ead752c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 9 Jul 2014 16:04:07 -0400 Subject: [PATCH] - Changed the default value of "raise_on_warnings" to False for MySQLconnector. This was set at True for some reason. The "buffered" flag unfortunately must stay at True as MySQLconnector does not allow a cursor to be closed unless all results are fully fetched. fixes #2515 - lots of MySQL tests seemed to not be hitting all backends, so we should be getting some mysqlconnector failures now --- doc/build/changelog/changelog_10.rst | 9 +++++++++ lib/sqlalchemy/dialects/mysql/mysqlconnector.py | 4 +++- test/dialect/mysql/test_dialect.py | 6 ++++-- test/dialect/mysql/test_query.py | 1 + test/dialect/mysql/test_reflection.py | 1 + test/dialect/mysql/test_types.py | 4 +++- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index de351326ed..57ca3c863e 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -16,6 +16,15 @@ .. changelog:: :version: 1.0.0 + .. change:: + :tags: mysql, bug + :tickets: 2515 + + Changed the default value of "raise_on_warnings" to False for + MySQLconnector. This was set at True for some reason. The "buffered" + flag unfortunately must stay at True as MySQLconnector does not allow + a cursor to be closed unless all results are fully fetched. + .. change:: :tags: bug, orm :tickets: 3117 diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index 3536c3ad81..83e731c163 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -87,8 +87,10 @@ class MySQLDialect_mysqlconnector(MySQLDialect): util.coerce_kw_type(opts, 'buffered', bool) util.coerce_kw_type(opts, 'raise_on_warnings', bool) + + # unfortunately, MySQL/connector python refuses to release a + # cursor without reading fully, so non-buffered isn't an option opts.setdefault('buffered', True) - opts.setdefault('raise_on_warnings', True) # FOUND_ROWS must be set in ClientFlag to enable # supports_sane_rowcount. diff --git a/test/dialect/mysql/test_dialect.py b/test/dialect/mysql/test_dialect.py index 2ff17f0f73..e6bad71a44 100644 --- a/test/dialect/mysql/test_dialect.py +++ b/test/dialect/mysql/test_dialect.py @@ -69,10 +69,11 @@ class DialectTest(fixtures.TestBase): )[1] eq_(kw['raise_on_warnings'], False) + kw = dialect.create_connect_args( make_url("mysql+mysqlconnector://u:p@host/db") )[1] - eq_(kw['raise_on_warnings'], True) + assert "raise_on_warnings" not in kw @testing.only_on('mysql') def test_random_arg(self): @@ -84,11 +85,11 @@ class DialectTest(fixtures.TestBase): class SQLModeDetectionTest(fixtures.TestBase): __only_on__ = 'mysql' + __backend__ = True def _options(self, modes): def connect(con, record): cursor = con.cursor() - print("DOING THiS:", "set sql_mode='%s'" % (",".join(modes))) cursor.execute("set sql_mode='%s'" % (",".join(modes))) e = engines.testing_engine(options={ 'pool_events':[ @@ -131,6 +132,7 @@ class ExecutionTest(fixtures.TestBase): """Various MySQL execution special cases.""" __only_on__ = 'mysql' + __backend__ = True def test_charset_caching(self): engine = engines.testing_engine() diff --git a/test/dialect/mysql/test_query.py b/test/dialect/mysql/test_query.py index 0400048086..dd11fe2b49 100644 --- a/test/dialect/mysql/test_query.py +++ b/test/dialect/mysql/test_query.py @@ -8,6 +8,7 @@ from sqlalchemy import testing class MatchTest(fixtures.TestBase, AssertsCompiledSQL): __only_on__ = 'mysql' + __backend__ = True @classmethod def setup_class(cls): diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py index c8fdc9310b..bf35a2c6bf 100644 --- a/test/dialect/mysql/test_reflection.py +++ b/test/dialect/mysql/test_reflection.py @@ -10,6 +10,7 @@ from sqlalchemy import testing class ReflectionTest(fixtures.TestBase, AssertsExecutionResults): __only_on__ = 'mysql' + __backend__ = True def test_default_reflection(self): """Test reflection of column defaults.""" diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index b7d261a886..f5901812e7 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -15,6 +15,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): "Test MySQL column types" __dialect__ = mysql.dialect() + __backend__ = True def test_numeric(self): "Exercise type specification and options for numeric types." @@ -257,7 +258,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): res ) - @testing.only_if('mysql') + @testing.only_if('mysql+mysqldb') @testing.exclude('mysql', '<', (5, 0, 5), 'a 5.0+ feature') @testing.provide_metadata def test_charset_collate_table(self): @@ -554,6 +555,7 @@ class EnumSetTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL __only_on__ = 'mysql' __dialect__ = mysql.dialect() + __backend__ = True @testing.provide_metadata -- 2.47.3