MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _generate_lazy_clause

Method _generate_lazy_clause

lib/sqlalchemy/orm/strategies.py:851–881  ·  view source on GitHub ↗
(self, state, passive)

Source from the content-addressed store, hash-verified

849 return criterion, params
850
851 def _generate_lazy_clause(self, state, passive):
852 criterion, param_keys = self._simple_lazy_clause
853
854 if state is None:
855 return sql_util.adapt_criterion_to_null(
856 criterion, [key for key, ident, value in param_keys]
857 )
858
859 mapper = self.parent_property.parent
860
861 o = state.obj() # strong ref
862 dict_ = attributes.instance_dict(o)
863
864 if passive & PassiveFlag.INIT_OK:
865 passive ^= PassiveFlag.INIT_OK
866
867 params = {}
868 for key, ident, value in param_keys:
869 if ident is not None:
870 if passive and passive & PassiveFlag.LOAD_AGAINST_COMMITTED:
871 value = mapper._get_committed_state_attr_by_column(
872 state, dict_, ident, passive
873 )
874 else:
875 value = mapper._get_state_attr_by_column(
876 state, dict_, ident, passive
877 )
878
879 params[key] = value
880
881 return criterion, params
882
883 def _invoke_raise_load(self, state, passive, lazy):
884 raise sa_exc.InvalidRequestError(

Callers 1

_emit_lazyloadMethod · 0.95

Tested by

no test coverage detected