Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

adding a key to a JsonField #37

Closed Jaymon closed 7 years ago

Jaymon commented 7 years ago

not sure what the fix for this looks like, but if you have a json field and that field contains a dict and then you modify that dict, it doesn't update the modified_fields and so if you call save() it won't actually save anything.

class Foo(Orm):
    bar = JsonField(True)

f = Foo.create(bar={"che": 1})
f.bar["baz"] = 2
f.save() # this won't actually update

f.modified_fields.add("bar")
f.save() # now it will update correctly
Jaymon commented 7 years ago

easiest fix would be to have the save look for JsonField or the like and just go ahead and add them to the list, I think this might be the best way to handle this