MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _do_check

Function _do_check

lib/sqlalchemy/orm/strategies.py:3519–3530  ·  view source on GitHub ↗
(state, value, oldvalue, initiator)

Source from the content-addressed store, hash-verified

3517
3518def _single_parent_validator(desc, prop):
3519 def _do_check(state, value, oldvalue, initiator):
3520 if value is not None and initiator.key == prop.key:
3521 hasparent = initiator.hasparent(attributes.instance_state(value))
3522 if hasparent and oldvalue is not value:
3523 raise sa_exc.InvalidRequestError(
3524 "Instance %s is already associated with an instance "
3525 "of %s via its %s attribute, and is only allowed a "
3526 "single parent."
3527 % (orm_util.instance_str(value), state.class_, prop),
3528 code="bbf1",
3529 )
3530 return value
3531
3532 def append(state, value, initiator):
3533 return _do_check(state, value, None, initiator)

Callers 2

appendFunction · 0.85
set_Function · 0.85

Calls 1

hasparentMethod · 0.45

Tested by

no test coverage detected