JSONEncodedDict with ext.mutable fails

Issue #2152 resolved
Former user created an issue

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)

  1. Former user Account Deleted

    Erm, please toss shazow at gmail onto the cc list. (Forgot to add myself.)

    • shazow
  2. Mike Bayer repo owner

    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.

  3. Mike Bayer repo owner

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

  4. Log in to comment