summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/mapper.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-07-05 11:16:26 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-07-05 11:16:26 -0400
commit6fcc5d4a07e5c409a7d8438582598d0e90562ea0 (patch)
treedb6255d902e3974c79d19cef6619bc58681a030e /lib/sqlalchemy/orm/mapper.py
parentcf21497f02e64b6ddec82e12a7c26b9476616b00 (diff)
downloadsqlalchemy-6fcc5d4a07e5c409a7d8438582598d0e90562ea0.tar.gz
- add a warning suggesting to use the dictionary form of access
if the name of the attribute being accessed is non-specific, thereby avoiding collisions on names like items, values, keys. fixes #3475
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r--lib/sqlalchemy/orm/mapper.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 468846d40..48fbaae32 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -2038,6 +2038,17 @@ class Mapper(InspectionAttr):
returned, inclding :attr:`.synonyms`, :attr:`.column_attrs`,
:attr:`.relationships`, and :attr:`.composites`.
+ .. warning::
+
+ the :attr:`.Mapper.relationships` accessor namespace is an
+ instance of :class:`.OrderedProperties`. This is
+ a dictionary-like object which includes a small number of
+ named methods such as :meth:`.OrderedProperties.items`
+ and :meth:`.OrderedProperties.values`. When
+ accessing attributes dynamically, favor using the dict-access
+ scheme, e.g. ``mapper.attrs[somename]`` over
+ ``getattr(mapper.attrs, somename)`` to avoid name collisions.
+
.. seealso::
:attr:`.Mapper.all_orm_descriptors`
@@ -2073,6 +2084,17 @@ class Mapper(InspectionAttr):
referring to the collection of mapped properties via
:attr:`.Mapper.attrs`.
+ .. warning::
+
+ the :attr:`.Mapper.relationships` accessor namespace is an
+ instance of :class:`.OrderedProperties`. This is
+ a dictionary-like object which includes a small number of
+ named methods such as :meth:`.OrderedProperties.items`
+ and :meth:`.OrderedProperties.values`. When
+ accessing attributes dynamically, favor using the dict-access
+ scheme, e.g. ``mapper.attrs[somename]`` over
+ ``getattr(mapper.attrs, somename)`` to avoid name collisions.
+
.. versionadded:: 0.8.0
.. seealso::
@@ -2114,6 +2136,17 @@ class Mapper(InspectionAttr):
"""Return a namespace of all :class:`.RelationshipProperty`
properties maintained by this :class:`.Mapper`.
+ .. warning::
+
+ the :attr:`.Mapper.relationships` accessor namespace is an
+ instance of :class:`.OrderedProperties`. This is
+ a dictionary-like object which includes a small number of
+ named methods such as :meth:`.OrderedProperties.items`
+ and :meth:`.OrderedProperties.values`. When
+ accessing attributes dynamically, favor using the dict-access
+ scheme, e.g. ``mapper.attrs[somename]`` over
+ ``getattr(mapper.attrs, somename)`` to avoid name collisions.
+
.. seealso::
:attr:`.Mapper.attrs` - namespace of all :class:`.MapperProperty`