MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / delete

Method delete

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

Source from the content-addressed store, hash-verified

1352 __slots__ = ()
1353
1354 def delete(self, state: InstanceState[Any], dict_: _InstanceDict) -> None:
1355 if self.dispatch._active_history:
1356 old = self.get(
1357 state,
1358 dict_,
1359 passive=PASSIVE_ONLY_PERSISTENT
1360 | NO_AUTOFLUSH
1361 | LOAD_AGAINST_COMMITTED,
1362 )
1363 else:
1364 old = self.get(
1365 state,
1366 dict_,
1367 passive=PASSIVE_NO_FETCH ^ INIT_OK
1368 | LOAD_AGAINST_COMMITTED
1369 | NO_RAISE,
1370 )
1371
1372 self.fire_remove_event(state, dict_, old, self._remove_token)
1373
1374 existing = dict_.pop(self.key, NO_VALUE)
1375
1376 # if the attribute is expired, we currently have no way to tell
1377 # that an object-attribute was expired vs. not loaded. So
1378 # for this test, we look to see if the object has a DB identity.
1379 if (
1380 existing is NO_VALUE
1381 and old is not PASSIVE_NO_RESULT
1382 and state.key is None
1383 ):
1384 raise AttributeError("%s object does not have a value" % self)
1385
1386 def get_history(
1387 self,

Callers

nothing calls this directly

Calls 3

fire_remove_eventMethod · 0.95
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected