MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / create

Method create

lib/sqlalchemy/orm/strategy_options.py:1732–1773  ·  view source on GitHub ↗

Create a new :class:`._LoadElement` object.

(
        cls,
        path: PathRegistry,
        attr: Union[_AttrType, _StrPathToken, None],
        strategy: Optional[_StrategyKey],
        wildcard_key: Optional[_WildcardKeyType],
        local_opts: Optional[_OptsType],
        propagate_to_loaders: bool,
        raiseerr: bool = True,
        attr_group: Optional[_AttrGroupType] = None,
        reconcile_to_other: Optional[bool] = None,
        extra_criteria: Optional[Tuple[Any, ...]] = None,
    )

Source from the content-addressed store, hash-verified

1730
1731 @classmethod
1732 def create(
1733 cls,
1734 path: PathRegistry,
1735 attr: Union[_AttrType, _StrPathToken, None],
1736 strategy: Optional[_StrategyKey],
1737 wildcard_key: Optional[_WildcardKeyType],
1738 local_opts: Optional[_OptsType],
1739 propagate_to_loaders: bool,
1740 raiseerr: bool = True,
1741 attr_group: Optional[_AttrGroupType] = None,
1742 reconcile_to_other: Optional[bool] = None,
1743 extra_criteria: Optional[Tuple[Any, ...]] = None,
1744 ) -> _LoadElement:
1745 """Create a new :class:`._LoadElement` object."""
1746
1747 opt = cls.__new__(cls)
1748 opt.path = path
1749 opt.strategy = strategy
1750 opt.propagate_to_loaders = propagate_to_loaders
1751 opt.local_opts = (
1752 util.immutabledict(local_opts) if local_opts else util.EMPTY_DICT
1753 )
1754 opt._extra_criteria = ()
1755
1756 if reconcile_to_other is not None:
1757 opt._reconcile_to_other = reconcile_to_other
1758 elif strategy is None and not local_opts:
1759 opt._reconcile_to_other = True
1760 else:
1761 opt._reconcile_to_other = None
1762
1763 path = opt._init_path(
1764 path, attr, wildcard_key, attr_group, raiseerr, extra_criteria
1765 )
1766
1767 if not path:
1768 return None # type: ignore
1769
1770 assert opt.is_token_strategy == path.is_token
1771
1772 opt.path = path
1773 return opt
1774
1775 def __init__(self) -> None:
1776 raise NotImplementedError()

Callers 3

_apply_to_parentMethod · 0.45
_processMethod · 0.45

Calls 2

__new__Method · 0.45
_init_pathMethod · 0.45

Tested by

no test coverage detected