JSONB field doesn't track changes

Issue #3410 resolved
Andrey Semenov created an issue

I have a code like this:

    stats = Column(JSONB, nullable=False, default={})

then having model object with:

In [17]: o.stats
Out[17]: {}

In [18]: id(o.stats)
Out[18]: 4377529152

I then modify stats column

In [20]: o.account_log(log)

In [21]: o.stats
Out[21]:
{'traffic': {'attempt_ts_spawn': 1430474948,
  'confirm_operator_id': 185,
  'confirm_ts_spawn': 1430474948}}

In [22]: id(o.stats)
Out[22]: 4375370840

at the end of account_log the stats is re-assigned with copy.deepcopy, but when doing Session.flush() I see no requests done to the server. As I understand sqlalchemy doesn't think there's any change to model made to flush it to server.

How could I ensure the changes are flushed to the SQL server?

Comments (1)

  1. Log in to comment