[Sqlalchemy-tickets] Issue #4277: mysql dialects client_flags work inconsistently per calling style
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2018-06-13 19:24:33
|
New issue 4277: mysql dialects client_flags work inconsistently per calling style https://bitbucket.org/zzzeek/sqlalchemy/issues/4277/mysql-dialects-client_flags-work Michael Bayer: because the dialects apply the FOUND_ROWS inside the create_connect_args method, if client_flags are passed in connect_args, the FOUND_ROWS flag is not applied: ``` #!python from sqlalchemy import create_engine from MySQLdb.constants import CLIENT from unittest import mock from MySQLdb import connect m1 = mock.Mock() def patch_mysql_connect(*arg, **kw): m1(*arg, **kw) return connect(*arg, **kw) with mock.patch("MySQLdb.connect", patch_mysql_connect): e1 = create_engine( "mysql+mysqldb://scott:tiger@localhost/test?client_flag=%s" % CLIENT.MULTI_STATEMENTS, ) e2 = create_engine( "mysql+mysqldb://scott:tiger@localhost/test", connect_args={"client_flag": CLIENT.MULTI_STATEMENTS} ) c1 = e1.connect() c2 = e2.connect() print(m1.mock_calls) assert m1.mock_calls[0] == m1.mock_calls[1] ``` output ``` #!python [call(client_flag=65538, db='test', host='localhost', passwd='tiger', user='scott'), call(client_flag=65536, db='test', host='localhost', passwd='tiger', user='scott')] Traceback (most recent call last): File "test.py", line 27, in <module> assert m1.mock_calls[0] == m1.mock_calls[1] AssertionError ``` we either need to change the API of create_connect_args to also accept the client arguments, which would break many third party dialects, pass them onto the URL, or add a new method so that the dialect gets access to the connect args. |