[Sqlalchemy-tickets] Issue #4072: `mysql.dml.Insert.values` shadows the generative function `sql.ex
Brought to you by:
zzzeek
From: Jack Z. <iss...@bi...> - 2017-09-09 00:30:22
|
New issue 4072: `mysql.dml.Insert.values` shadows the generative function `sql.expression.Insert.values` https://bitbucket.org/zzzeek/sqlalchemy/issues/4072/mysqldmlinsertvalues-shadows-the Jack Zhou: When using the `ON DUPLICATE KEY UPDATE` support for MySQL, the `.values()` generative function is not available, contrary to the claims made by the [documentation](http://docs.sqlalchemy.org/en/latest/dialects/mysql.html#mysql-insert-on-duplicate-key-update). ``` Traceback (most recent call last): File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "kronos/__main__.py", line 97, in <module> cli() File "/home/ashu/Documents/kronos/venv/lib/python3.5/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/home/ashu/Documents/kronos/venv/lib/python3.5/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "kronos/__main__.py", line 31, in invoke return super(CLI, self).invoke(ctx) File "/home/ashu/Documents/kronos/venv/lib/python3.5/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/ashu/Documents/kronos/venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/ashu/Documents/kronos/venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/home/ashu/Documents/kronos/scripts/gilmore_from_scratch.py", line 46, in gilmore_from_scratch stmt = insert(GilmoreItem.__table__).values(**to_insert) TypeError: 'ImmutableColumnCollection' object is not callable ``` It appears to be shadowed by the `.values` property intended to support the `VALUES(...)` construct. Perhaps the column collection could be named `values_` instead? The workaround is to specify `values` with the `insert` constructor: ``` stmt = insert(GilmoreItem.__table__, values=to_insert) ``` |