sqlaclhemy ORM don't update jsonb[postgres-psycopg2]

93 views
Skip to first unread message

Yaser Abbasi

unread,
Jun 30, 2015, 5:54:56 AM6/30/15
to sqlal...@googlegroups.com
Hi,

Sqlalchemy orm don't find out jsonb changes for update when call 
for example Model.add(obj) !!!

now I use Model.update({"jsonb_filed_name":jsonb_filed_name})

What is problem?

thanks,
best


Jonathan Vanasco

unread,
Jun 30, 2015, 11:01:14 AM6/30/15
to sqlal...@googlegroups.com
This sounds like you may be having issues with mutation tracking on edits.
 

The JSON type, when used with the SQLAlchemy ORM, does not detect in-place mutations to the structure. In order to detect these, the sqlalchemy.ext.mutable extension must be used. This extension will allow “in-place” changes to the datastructure to produce events which will be detected by the unit of work. See the example at HSTORE for a simple example involving a dictionary.

Mutation Tracking

HSTORE example
Reply all
Reply to author
Forward
0 new messages