module documentation

private module containing functions used to emit INSERT, UPDATE and DELETE statements on behalf of a :class:`_orm.Mapper` and its descending mappers. The functions here are called only by the unit of work functions in unitofwork.py.

Function delete_obj Issue ``DELETE`` statements for a list of objects.
Function post_update Issue UPDATE statements on behalf of a relationship() which specifies post_update.
Function save_obj Issue ``INSERT`` and/or ``UPDATE`` statements for a list of objects.
Function _collect_delete_commands Identify values to use in DELETE statements for a list of states to be deleted.
Function _collect_insert_commands Identify sets of values to use in INSERT statements for a list of states.
Function _collect_post_update_commands Identify sets of values to use in UPDATE statements for a list of states within a post_update operation.
Function _collect_update_commands Identify sets of values to use in UPDATE statements for a list of states.
Function _connections_for_states Return an iterator of (state, state.dict, mapper, connection).
Function _emit_delete_statements Emit DELETE statements corresponding to value lists collected by _collect_delete_commands().
Function _emit_insert_statements Emit INSERT statements corresponding to value lists collected by _collect_insert_commands().
Function _emit_post_update_statements Emit UPDATE statements corresponding to value lists collected by _collect_post_update_commands().
Function _emit_update_statements Emit UPDATE statements corresponding to value lists collected by _collect_update_commands().
Function _finalize_insert_update_commands finalize state on states that have been inserted or updated, including calling after_insert/after_update events.
Function _organize_states_for_delete Make an initial pass across a set of states for DELETE.
Function _organize_states_for_post_update Make an initial pass across a set of states for UPDATE corresponding to post_update.
Function _organize_states_for_save Make an initial pass across a set of states for INSERT or UPDATE.
Function _postfetch Expire attributes in need of newly persisted database state, after an INSERT or UPDATE statement has proceeded for that state.
Function _postfetch_bulk_save Undocumented
Function _postfetch_post_update Undocumented
Function _sort_states Undocumented
def delete_obj(base_mapper, states, uowtransaction): (source)

Issue ``DELETE`` statements for a list of objects. This is called within the context of a UOWTransaction during a flush operation.

def post_update(base_mapper, states, uowtransaction, post_update_cols): (source)

Issue UPDATE statements on behalf of a relationship() which specifies post_update.

def save_obj(base_mapper, states, uowtransaction, single=False): (source)

Issue ``INSERT`` and/or ``UPDATE`` statements for a list of objects. This is called within the context of a UOWTransaction during a flush operation, given a list of states to be flushed. The base mapper in an inheritance hierarchy handles the inserts/ updates for all descendant mappers.

def _collect_delete_commands(base_mapper, uowtransaction, table, states_to_delete): (source)

Identify values to use in DELETE statements for a list of states to be deleted.

def _collect_insert_commands(table, states_to_insert, bulk=False, return_defaults=False, render_nulls=False): (source)

Identify sets of values to use in INSERT statements for a list of states.

def _collect_post_update_commands(base_mapper, uowtransaction, table, states_to_update, post_update_cols): (source)

Identify sets of values to use in UPDATE statements for a list of states within a post_update operation.

def _collect_update_commands(uowtransaction, table, states_to_update, bulk=False, use_orm_update_stmt=None): (source)

Identify sets of values to use in UPDATE statements for a list of states. This function works intricately with the history system to determine exactly what values should be updated as well as how the row should be matched within an UPDATE statement. Includes some tricky scenarios where the primary key of an object might have been changed.

def _connections_for_states(base_mapper, uowtransaction, states): (source)

Return an iterator of (state, state.dict, mapper, connection). The states are sorted according to _sort_states, then paired with the connection they should be using for the given unit of work transaction.

def _emit_delete_statements(base_mapper, uowtransaction, mapper, table, delete): (source)

Emit DELETE statements corresponding to value lists collected by _collect_delete_commands().

def _emit_insert_statements(base_mapper, uowtransaction, mapper, table, insert, bookkeeping=True, use_orm_insert_stmt=None, execution_options=None): (source)

Emit INSERT statements corresponding to value lists collected by _collect_insert_commands().

def _emit_post_update_statements(base_mapper, uowtransaction, mapper, table, update): (source)

Emit UPDATE statements corresponding to value lists collected by _collect_post_update_commands().

def _emit_update_statements(base_mapper, uowtransaction, mapper, table, update, bookkeeping=True, use_orm_update_stmt=None): (source)

Emit UPDATE statements corresponding to value lists collected by _collect_update_commands().

def _finalize_insert_update_commands(base_mapper, uowtransaction, states): (source)

finalize state on states that have been inserted or updated, including calling after_insert/after_update events.

def _organize_states_for_delete(base_mapper, states, uowtransaction): (source)

Make an initial pass across a set of states for DELETE. This includes calling out before_delete and obtaining key information for each state including its dictionary, mapper, the connection to use for the execution per state.

def _organize_states_for_post_update(base_mapper, states, uowtransaction): (source)

Make an initial pass across a set of states for UPDATE corresponding to post_update. This includes obtaining key information for each state including its dictionary, mapper, the connection to use for the execution per state.

def _organize_states_for_save(base_mapper, states, uowtransaction): (source)

Make an initial pass across a set of states for INSERT or UPDATE. This includes splitting out into distinct lists for each, calling before_insert/before_update, obtaining key information for each state including its dictionary, mapper, the connection to use for the execution per state, and the identity flag.

def _postfetch(mapper, uowtransaction, table, state, dict_, result, params, value_params, isupdate, returned_defaults): (source)

Expire attributes in need of newly persisted database state, after an INSERT or UPDATE statement has proceeded for that state.

def _postfetch_bulk_save(mapper, dict_, table): (source)

Undocumented

def _postfetch_post_update(mapper, uowtransaction, table, state, dict_, result, params): (source)

Undocumented

def _sort_states(mapper, states): (source)

Undocumented