We have a model with a JSON field where user flags get inserted. Inserting does work as expected, but when removing certain flags, they stay in the field and changes don't get persisted to the DB.
We have the following method in our model:
def del_flag(self, key):
if self.user_flags is None or not key in self.user_flags:
return False
else:
del self.user_flags[key]
db.session.commit()
return True
The databasse is postgres and we use the SQLalchemy JSON field dialect for the field type. Any advice on this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…