module documentation

private module containing functions used to emit INSERT, UPDATE and DELETE statements on behalf of a _orm.Mapper and its descending mappers.

The functions here are called only by the unit of work functions in unitofwork.py.

Class ​Bulk​ORMDelete Undocumented
Class ​Bulk​ORMUpdate Undocumented
Class ​Bulk​UDCompile​State No class docstring; 1/7 class method, 0/1 class documented
Function ​_bulk​_insert Undocumented
Function ​_bulk​_update Undocumented
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
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.
Constant ​_EMPTY​_DICT Undocumented
def _bulk_insert(mapper, mappings, session_transaction, isstates, return_defaults, render_nulls):

Undocumented

def _bulk_update(mapper, mappings, session_transaction, isstates, update_changed_only):

Undocumented

def _collect_delete_commands(base_mapper, uowtransaction, table, states_to_delete):
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):
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):
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):

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):

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):
Emit DELETE statements corresponding to value lists collected by _collect_delete_commands().
def _emit_insert_statements(base_mapper, uowtransaction, mapper, table, insert, bookkeeping=True):
Emit INSERT statements corresponding to value lists collected by _collect_insert_commands().
def _emit_post_update_statements(base_mapper, uowtransaction, mapper, table, update):
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):
Emit UPDATE statements corresponding to value lists collected by _collect_update_commands().
def _finalize_insert_update_commands(base_mapper, uowtransaction, states):
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):

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):

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):

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):
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):

Undocumented

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

Undocumented

def _sort_states(mapper, states):

Undocumented

def delete_obj(base_mapper, states, uowtransaction):

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):
Issue UPDATE statements on behalf of a relationship() which specifies post_update.
def save_obj(base_mapper, states, uowtransaction, single=False):

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.

_EMPTY_DICT =

Undocumented

Value
util.immutabledict()