`mysql.dml.Insert.values` shadows the generative function `sql.expression.Insert.values`
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.
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)
Comments (5)
-
repo owner -
repo owner anyway nice catch! https://gerrit.sqlalchemy.org/510 it's called .inserted now.
-
repo owner - changed status to resolved
Rename MySQL dml.insert().values to .inserted
Changed the name of the
.values
attribute of the new MySQL INSERT..ON DUPLICATE KEY UPDATE construct to.inserted
, as :class:.Insert
already has a method called :meth:.Insert.values
. The.inserted
attribute ultimately renders the MySQLVALUES()
function.Change-Id: I8da8e30a3077698385a4b77e2c2032e2d1ff10b2 Fixes:
#4072→ <<cset 70be7312f10a>>
-
repo owner thanks, we dodged a bullet on that one. whenever i see a bug report from you I know im going to have to fix something for real... :)
-
reporter Happy to help. And thank you for the quick fix as always!
- Log in to comment
doh. clearly it has to be some totally different name.