JSONEncodedDict with ext.mutable fails
When following the example verbatim on /docs/07/orm/extensions/mutable.html, the changed event gets fired properly, but nothing gets saved.
class MyDataClass(Base):
__tablename__ = 'my_data'
id = Column(Integer, primary_key=True)
data = Column(MutationDict.as_mutable(JSONEncodedDict))
# ...
f = MyDataClass(data={'value1':'foo'})
s.add(f)
s.commit()
s.refresh(f)
print f.data # -> {}
# All of these variations fail to save any data too
f.data.update({'foo': 'bar'})
f.data['foo']('foo') = 'bar'
f.data = {'foo': 'bar'} # raises NameError due to [#2143](issue)
Test script attached.
Comments (5)
-
Account Deleted -
repo owner - changed watchers to shazow@gmail.com
weird, trying to see which part of your test looks at all different from the unit test in test_mutable - the code is straight from the unit test. Just the usage of declarative.
-
repo owner - changed component to documentation
OK its just the usage of collections.MutableMapping. i think the docs need to pay a higher ABC tax if we're going to illustrate the usage of it, so lets see what GVR forms in triplicate I need for it to do what I tell it...
-
repo owner - changed status to resolved
the solution is to put
dict
beforecollections.MutableMapping
in the inherit list, but I took out the usage ofMutableMapping
altogether in 425b7388cc7808751bd73a647c05fc669ea6dbbf. -
repo owner - removed milestone
Removing milestone: 0.7.0 (automated comment)
- Log in to comment
Erm, please toss shazow at gmail onto the cc list. (Forgot to add myself.)