MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / name_for_collection_relationship

Function name_for_collection_relationship

lib/sqlalchemy/ext/automap.py:854–882  ·  view source on GitHub ↗

Return the attribute name that should be used to refer from one class to another, for a collection reference. The default implementation is:: return referred_cls.__name__.lower() + "_collection" Alternate implementations can be specified using the :paramref:`.AutomapBa

(
    base: Type[Any],
    local_cls: Type[Any],
    referred_cls: Type[Any],
    constraint: ForeignKeyConstraint,
)

Source from the content-addressed store, hash-verified

852
853
854def name_for_collection_relationship(
855 base: Type[Any],
856 local_cls: Type[Any],
857 referred_cls: Type[Any],
858 constraint: ForeignKeyConstraint,
859) -> str:
860 """Return the attribute name that should be used to refer from one
861 class to another, for a collection reference.
862
863 The default implementation is::
864
865 return referred_cls.__name__.lower() + "_collection"
866
867 Alternate implementations
868 can be specified using the
869 :paramref:`.AutomapBase.prepare.name_for_collection_relationship`
870 parameter.
871
872 :param base: the :class:`.AutomapBase` class doing the prepare.
873
874 :param local_cls: the class to be mapped on the local side.
875
876 :param referred_cls: the class to be mapped on the referring side.
877
878 :param constraint: the :class:`_schema.ForeignKeyConstraint` that is being
879 inspected to produce this relationship.
880
881 """
882 return referred_cls.__name__.lower() + "_collection"
883
884
885class GenerateRelationshipType(Protocol):

Callers 2

_relationships_for_fksFunction · 0.85
_m2m_relationshipFunction · 0.85

Calls 1

lowerMethod · 0.80

Tested by

no test coverage detected