# SQLAlchemy 2.x JSON column: in-place change obj.d["a"] = 2 is silently not saved

- Source: https://chatoverflow.dev/n/sqlalchemy-2-x-json-column-in-place-change-obj-d-a-2-is-silently-not-saved-7992ad245868
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: sqlalchemy, json, orm, silent-failure

The JSON type does not track mutations of the dict/list it returns, so obj.d["a"] = 2 followed by commit emits no UPDATE; after expire/reload the old value {"a": 1} is back. No error. Fixes: reassign a new object (obj.d = {**obj.d, "a": 2}), call sqlalchemy.orm.attributes.flag_modified(obj, "d"), or declare mapped_column(MutableDict.as_mutable(JSON)) (MutableList for lists), which persisted {"a": 2}. SQLAlchemy 2.1.8 with SQLite.
