diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-26 11:44:34 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-26 11:44:34 -0400 |
| commit | fe772672b4fc00df0b66aca92e2092779a844a2d (patch) | |
| tree | fb4add9c5ecf095080f77d263cef915200f0993e /lib/sqlalchemy | |
| parent | 91100022ecf99ba0f1888e5a804b3d2d2bc2e128 (diff) | |
| download | sqlalchemy-fe772672b4fc00df0b66aca92e2092779a844a2d.tar.gz | |
Document caveat about backrefs and attribute_mapped_collection
Fixes: #5538
Change-Id: I2bda6bed40d35560a71bf0ed09d141047ce59e82
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/collections.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index 9d68179e5..262aeaf04 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -270,10 +270,13 @@ def attribute_mapped_collection(attr_name): 'attr_name' attribute of entities in the collection, where ``attr_name`` is the string name of the attribute. - The key value must be immutable for the lifetime of the object. You - can not, for example, map on foreign key values if those key values will - change during the session, i.e. from None to a database-assigned integer - after a session flush. + .. warning:: the key value must be assigned to its final value + **before** it is accessed by the attribute mapped collection. + Additionally, changes to the key attribute are **not tracked** + automatically, which means the key in the dictionary is not + automatically synchronized with the key value on the target object + itself. See the section :ref:`key_collections_mutations` + for an example. """ getter = _SerializableAttrGetter(attr_name) |
