- changed status to invalid
cannot use JsonColumn recipie if column has primary_key=True set
Issue #2126
resolved
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/JSONColumn
ive tried this recipie for this class
SomeClass(obj)
channel_json_conf = sa.Column(JSONCol(), primary_key=True,
nullable=False, default='')
the problem was serialisation only worked for immutable types like string, for mutable types i got following exception:
self.session.flush()
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/session.py', line 1388 in flush
self._flush(objects)
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/session.py', line 1469 in _flush
flush_context.execute()
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.py', line 302 in execute
rec.execute(self)
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.py', line 446 in execute
uow
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/mapper.py', line 1640 in _save_obj
instance_key in uowtransaction.session.identity_map:
File '/home/ergo/python/lib/python2.6/site-packages/sqlalchemy/orm/identity.py', line 99 in __contains__
if dict.__contains__(self, key):
TypeError: unhashable type: 'dict'
when i remove primary_key from the column definition everything works fine for both mutable and immutable types.
Comments (1)
-
repo owner - Log in to comment
sorry, this is not a bug for two reasons.