Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé
Module « sqlalchemy.orm »

Fonction column_keyed_dict - module sqlalchemy.orm

Signature de la fonction column_keyed_dict

def column_keyed_dict(mapping_spec: 'Union[Type[_KT], Callable[[_KT], _VT]]', *, ignore_unpopulated_attribute: 'bool' = False) -> 'Type[KeyFuncDict[_KT, _KT]]' 

Description

help(sqlalchemy.orm.column_keyed_dict)

A dictionary-based collection type with column-based keying.

.. versionchanged:: 2.0 Renamed :data:`.column_mapped_collection` to
   :class:`.column_keyed_dict`.

Returns a :class:`.KeyFuncDict` factory which will produce new
dictionary keys based on the value of a particular :class:`.Column`-mapped
attribute on ORM mapped instances to be added to the dictionary.

.. note:: the value of the target attribute must be assigned with its
   value at the time that the object is being added to the
   dictionary collection.   Additionally, changes to the key attribute
   are **not tracked**, which means the key in the dictionary is not
   automatically synchronized with the key value on the target object
   itself.  See :ref:`key_collections_mutations` for further details.

.. seealso::

    :ref:`orm_dictionary_collection` - background on use

:param mapping_spec: a :class:`_schema.Column` object that is expected
 to be mapped by the target mapper to a particular attribute on the
 mapped class, the value of which on a particular instance is to be used
 as the key for a new dictionary entry for that instance.
:param ignore_unpopulated_attribute:  if True, and the mapped attribute
 indicated by the given :class:`_schema.Column` target attribute
 on an object is not populated at all, the operation will be silently
 skipped.  By default, an error is raised.

 .. versionadded:: 2.0 an error is raised by default if the attribute
    being used for the dictionary key is determined that it was never
    populated with any value.  The
    :paramref:`_orm.column_keyed_dict.ignore_unpopulated_attribute`
    parameter may be set which will instead indicate that this condition
    should be ignored, and the append operation silently skipped.
    This is in contrast to the behavior of the 1.x series which would
    erroneously populate the value in the dictionary with an arbitrary key
    value of ``None``.




Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé