MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / delete

Method delete

lib/sqlalchemy/orm/attributes.py:1233–1250  ·  view source on GitHub ↗
(self, state: InstanceState[Any], dict_: _InstanceDict)

Source from the content-addressed store, hash-verified

1231 self._remove_token = AttributeEventToken(self, OP_REMOVE)
1232
1233 def delete(self, state: InstanceState[Any], dict_: _InstanceDict) -> None:
1234 if self.dispatch._active_history:
1235 old = self.get(state, dict_, PASSIVE_RETURN_NO_VALUE)
1236 else:
1237 old = dict_.get(self.key, NO_VALUE)
1238
1239 if self.dispatch.remove:
1240 self.fire_remove_event(state, dict_, old, self._remove_token)
1241 state._modified_event(dict_, self, old)
1242
1243 existing = dict_.pop(self.key, NO_VALUE)
1244 if (
1245 existing is NO_VALUE
1246 and old is NO_VALUE
1247 and not state.expired
1248 and self.key not in state.expired_attributes
1249 ):
1250 raise AttributeError("%s object does not have a value" % self)
1251
1252 def get_history(
1253 self,

Callers

nothing calls this directly

Calls 4

fire_remove_eventMethod · 0.95
getMethod · 0.45
_modified_eventMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected