`mysql.dml.Insert.values` shadows the generative function `sql.expression.Insert.values`

Issue #4072 resolved
Jack Zhou
created an issue

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>
  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)

  1. Mike Bayer repo owner

    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 MySQL VALUES() function.

    Change-Id: I8da8e30a3077698385a4b77e2c2032e2d1ff10b2 Fixes: #4072

    → <<cset 70be7312f10a>>

  2. Log in to comment