diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-20 12:24:40 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-04-20 15:59:37 -0400 |
| commit | 6abbda34ebb2c154ccae12d749968fe72f27f372 (patch) | |
| tree | ed8d093e3153e0866107e5222a176b464ecd2bd7 /doc/build/orm | |
| parent | fe35828eefc00e12e01df25f6fd942eecde1a686 (diff) | |
| download | sqlalchemy-6abbda34ebb2c154ccae12d749968fe72f27f372.tar.gz | |
Add ColumnProperty.Comparator.expressions
Added an accessor :attr:`.ColumnProperty.Comparator.expressions` which
provides access to the group of columns mapped under a multi-column
:class:`.ColumnProperty` attribute.
Fixes: #5262
Change-Id: I44cf53ff0e6cf76a0c90eee4638ca96da3df8088
Diffstat (limited to 'doc/build/orm')
| -rw-r--r-- | doc/build/orm/internals.rst | 11 | ||||
| -rw-r--r-- | doc/build/orm/nonstandard_mappings.rst | 13 |
2 files changed, 24 insertions, 0 deletions
diff --git a/doc/build/orm/internals.rst b/doc/build/orm/internals.rst index d0e7c1ce4..e9f1b431e 100644 --- a/doc/build/orm/internals.rst +++ b/doc/build/orm/internals.rst @@ -21,6 +21,17 @@ sections, are listed here. .. autoclass:: sqlalchemy.orm.properties.ColumnProperty :members: + .. attribute:: Comparator.expressions + + The full sequence of columns referenced by this + attribute, adjusted for any aliasing in progress. + + .. versionadded:: 1.3.17 + + .. seealso:: + + :ref:`maptojoin` - usage example + .. autoclass:: sqlalchemy.orm.descriptor_props.CompositeProperty :members: diff --git a/doc/build/orm/nonstandard_mappings.rst b/doc/build/orm/nonstandard_mappings.rst index 01a615ae2..81679dd01 100644 --- a/doc/build/orm/nonstandard_mappings.rst +++ b/doc/build/orm/nonstandard_mappings.rst @@ -68,6 +68,19 @@ The natural primary key of the above mapping is the composite of is represented from an ``AddressUser`` object as ``(AddressUser.id, AddressUser.address_id)``. +When referring to the ``AddressUser.id`` column, most SQL expressions will +make use of only the first column in the list of columns mapped, as the +two columns are synonymous. However, for the special use case such as +a GROUP BY expression where both columns must be referenced at the same +time while making use of the proper context, that is, accommodating for +aliases and similar, the accessor :attr:`.ColumnProperty.Comparator.expressions` +may be used:: + + q = session.query(AddressUser).group_by(*AddressUser.id.expressions) + +.. versionadded:: 1.3.17 Added the + :attr:`.ColumnProperty.Comparator.expressions` accessor. + .. note:: |
