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