inconshreveable/sqltap

TypeError: unhashable type: 'NestedMutable'

HeyBillFinn opened this issue · 3 comments

When using SQLAlchemy and a JSON and/or HSTORE column, SQL tap attempts to hash an unhashable type:

  File "/home/vagrant/local/venv/local/lib/python2.7/site-packages/sqlalchemy/event/attr.py", line 256, in __call__
    fn(*args, **kw)
  File "/home/vagrant/local/venv/local/lib/python2.7/site-packages/sqltap/sqltap.py", line 188, in _after_exec
    context, params_dict, results)
  File "/home/vagrant/local/venv/local/lib/python2.7/site-packages/sqltap/sqltap.py", line 64, in __init__
    self.params_hash = self.calculate_params_hash(self.params)
  File "/home/vagrant/local/venv/local/lib/python2.7/site-packages/sqltap/sqltap.py", line 71, in calculate_params_hash
    h ^= 10009 * hash(params[k])
TypeError: unhashable type: 'NestedMutable'

Current workaround in sqltap.py, line 71:

-            h ^= 10009 * hash(params[k])
+            if isinstance(params[k], collections.Hashable):
+                h ^= 10009 * hash(params[k])

Interesting.. it looks like this was fixed on master? hash(params[k]) is changed to hash(repr(params[k])).

https://github.com/inconshreveable/sqltap/blob/master/sqltap/sqltap.py#L75

When I did a fresh install of the package, I received version 0.3.10, which still has the broken code.

published 0.3.11 to pypi

Awesome, thanks!