MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / declarative_scan

Method declarative_scan

lib/sqlalchemy/orm/properties.py:713–751  ·  view source on GitHub ↗
(
        self,
        decl_scan: _DeclarativeMapperConfig,
        registry: _RegistryType,
        cls: Type[Any],
        originating_module: Optional[str],
        key: str,
        mapped_container: Optional[Type[Mapped[Any]]],
        annotation: Optional[_AnnotationScanType],
        extracted_mapped_annotation: Optional[_AnnotationScanType],
        is_dataclass_field: bool,
    )

Source from the content-addressed store, hash-verified

711 return given_column
712
713 def declarative_scan(
714 self,
715 decl_scan: _DeclarativeMapperConfig,
716 registry: _RegistryType,
717 cls: Type[Any],
718 originating_module: Optional[str],
719 key: str,
720 mapped_container: Optional[Type[Mapped[Any]]],
721 annotation: Optional[_AnnotationScanType],
722 extracted_mapped_annotation: Optional[_AnnotationScanType],
723 is_dataclass_field: bool,
724 ) -> None:
725 column = self.column
726
727 column = self.column = self._adjust_for_existing_column(
728 decl_scan, key, self.column
729 )
730
731 if column.key is None:
732 column.key = key
733 if column.name is None:
734 column.name = key
735
736 sqltype = column.type
737
738 if extracted_mapped_annotation is None:
739 if sqltype._isnull and not self.column.foreign_keys:
740 self._raise_for_required(key, cls)
741 else:
742 return
743
744 self._init_column_for_annotation(
745 cls,
746 decl_scan,
747 key,
748 registry,
749 extracted_mapped_annotation,
750 originating_module,
751 )
752
753 @util.preload_module("sqlalchemy.orm.decl_base")
754 def declarative_scan_for_composite(

Callers 2

__get__Method · 0.45

Calls 3

_raise_for_requiredMethod · 0.80

Tested by

no test coverage detected