MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / adds

Method adds

lib/sqlalchemy/orm/collections.py:322–343  ·  view source on GitHub ↗

Mark the method as adding an entity to the collection. Adds "add to collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value. Arguments can be specified positionally (i.e. integer) or by name::

(arg: int)

Source from the content-addressed store, hash-verified

320
321 @staticmethod
322 def adds(arg: int) -> Callable[[_FN], _FN]:
323 """Mark the method as adding an entity to the collection.
324
325 Adds "add to collection" handling to the method. The decorator
326 argument indicates which method argument holds the SQLAlchemy-relevant
327 value. Arguments can be specified positionally (i.e. integer) or by
328 name::
329
330 @collection.adds(1)
331 def push(self, item): ...
332
333
334 @collection.adds("entity")
335 def do_stuff(self, thing, entity=None): ...
336
337 """
338
339 def decorator(fn):
340 fn._sa_instrument_before = ("fire_append_event", arg)
341 return fn
342
343 return decorator
344
345 @staticmethod
346 def replaces(arg):

Callers 1

OrderingListClass · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected