MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _collect_delete_commands

Function _collect_delete_commands

lib/sqlalchemy/orm/persistence.py:694–729  ·  view source on GitHub ↗

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

(
    base_mapper, uowtransaction, table, states_to_delete
)

Source from the content-addressed store, hash-verified

692
693
694def _collect_delete_commands(
695 base_mapper, uowtransaction, table, states_to_delete
696):
697 """Identify values to use in DELETE statements for a list of
698 states to be deleted."""
699
700 for (
701 state,
702 state_dict,
703 mapper,
704 connection,
705 update_version_id,
706 ) in states_to_delete:
707 if table not in mapper._pks_by_table:
708 continue
709
710 params = {}
711 for col in mapper._pks_by_table[table]:
712 params[col.key] = value = (
713 mapper._get_committed_state_attr_by_column(
714 state, state_dict, col
715 )
716 )
717 if value is None:
718 raise orm_exc.FlushError(
719 "Can't delete from table %s "
720 "using NULL for primary "
721 "key value on column %s" % (table, col)
722 )
723
724 if (
725 update_version_id is not None
726 and mapper.version_id_col in mapper._cols_by_table[table]
727 ):
728 params[mapper.version_id_col.key] = update_version_id
729 yield params, connection
730
731
732def _emit_update_statements(

Callers 1

_delete_objFunction · 0.85

Tested by

no test coverage detected