[Sqlalchemy-tickets] Issue #4136: In MySQL, visit_concat_op_binary does not forward kwargs (zzzeek/
Brought to you by:
zzzeek
From: ploutch <iss...@bi...> - 2017-11-13 10:27:19
|
New issue 4136: In MySQL, visit_concat_op_binary does not forward kwargs https://bitbucket.org/zzzeek/sqlalchemy/issues/4136/in-mysql-visit_concat_op_binary-does-not ploutch: In `sqlalchemy.dialects.mysql.base`, line 817, `visit_concat_op_binary` should pass its keyword arguments to both calls of `self.process`. The bug happened when using the `CreateView` recipe from https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Views . Something like this should reproduce the bug: import sqlalchemy as sa from sqlalchemy.schema import DDLElement from sqlalchemy.ext import compiler class CreateView(DDLElement): __visit_name__ = "create_view" def __init__(self, name, selectable, or_replace=False): super(CreateView, self).__init__() self.name = name self.selectable = selectable self.or_replace = or_replace @compiler.compiles(CreateView) def compile_create(element, compiler, **kw): cmd = ( 'CREATE OR REPLACE' if element.or_replace else 'CREATE', 'VIEW', element.name, 'AS', compiler.sql_compiler.process(element.selectable, literal_binds=True) ) return ' '.join(cmd) definition = sa.select([table.c.value]).where(table.c.value.contains('foo')) query = CreateView('bar', definition) engine.execute(query) (Considering that `engine` is an Engine and `table` is a Table with a string column called `value`) You should obtain the given traceback when running the query: File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2064, in execute return connection.execute(statement, *multiparams, **params) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute return meth(self, multiparams, params) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection return connection._execute_ddl(self, multiparams, params) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1002, in _execute_ddl compiled File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context context) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception util.reraise(*exc_info) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context context) File "/home/user/dev/env_201601/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute cursor.execute(statement, parameters) File "/home/user/dev/env_201601/lib/python2.7/site-packages/MySQLdb/cursors.py", line 187, in execute query = query % tuple([db.literal(item) for item in args]) TypeError: not enough arguments for format string Database: MySQL 5.5.57 |