MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / append

Function append

lib/sqlalchemy/orm/unitofwork.py:49–70  ·  view source on GitHub ↗
(state, item, initiator, **kw)

Source from the content-addressed store, hash-verified

47 key = prop.key
48
49 def append(state, item, initiator, **kw):
50 # process "save_update" cascade rules for when
51 # an instance is appended to the list of another instance
52
53 if item is None:
54 return
55
56 sess = state.session
57 if sess:
58 if sess._warn_on_events:
59 sess._flush_warning("collection append")
60
61 prop = state.manager.mapper._props[key]
62 item_state = attributes.instance_state(item)
63
64 if (
65 prop._cascade.save_update
66 and (key == initiator.key)
67 and not sess._contains_state(item_state)
68 ):
69 sess._save_or_update_state(item_state)
70 return item
71
72 def remove(state, item, initiator, **kw):
73 if item is None:

Callers

nothing calls this directly

Calls 3

_flush_warningMethod · 0.80
_contains_stateMethod · 0.80
_save_or_update_stateMethod · 0.80

Tested by

no test coverage detected