MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / name_for_scalar_relationship

Function name_for_scalar_relationship

lib/sqlalchemy/ext/automap.py:814–841  ·  view source on GitHub ↗

Return the attribute name that should be used to refer from one class to another, for a scalar object reference. The default implementation is:: return referred_cls.__name__.lower() Alternate implementations can be specified using the :paramref:`.AutomapBase.prepare.name_f

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

Source from the content-addressed store, hash-verified

812
813
814def name_for_scalar_relationship(
815 base: Type[Any],
816 local_cls: Type[Any],
817 referred_cls: Type[Any],
818 constraint: ForeignKeyConstraint,
819) -> str:
820 """Return the attribute name that should be used to refer from one
821 class to another, for a scalar object reference.
822
823 The default implementation is::
824
825 return referred_cls.__name__.lower()
826
827 Alternate implementations can be specified using the
828 :paramref:`.AutomapBase.prepare.name_for_scalar_relationship`
829 parameter.
830
831 :param base: the :class:`.AutomapBase` class doing the prepare.
832
833 :param local_cls: the class to be mapped on the local side.
834
835 :param referred_cls: the class to be mapped on the referring side.
836
837 :param constraint: the :class:`_schema.ForeignKeyConstraint` that is being
838 inspected to produce this relationship.
839
840 """
841 return referred_cls.__name__.lower()
842
843
844class NameForCollectionRelationshipType(Protocol):

Callers 1

_relationships_for_fksFunction · 0.85

Calls 1

lowerMethod · 0.80

Tested by

no test coverage detected