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

    for state, state_dict, mapper, connection in states_to_update:

        # assert table in mapper._pks_by_table

        pks = mapper._pks_by_table[table]
        params = {}
        hasdata = False

        for col in mapper._cols_by_table[table]:
            if col in pks:
                params[col._label] = \
                    mapper._get_state_attr_by_column(
                        state,
                        state_dict, col, passive=attributes.PASSIVE_OFF)

            elif col in post_update_cols:
                prop = mapper._columntoproperty[col]
                history = state.manager[prop.key].impl.get_history(
                    state, state_dict,
                    attributes.PASSIVE_NO_INITIALIZE)
                if history.added:
                    value = history.added[0]
                    params[col.key] = value
                    hasdata = True
        if hasdata:
            yield params, connection
Identify sets of values to use in UPDATE statements for a
dataset/ETHPy150Open zzzeek/sqlalchemy/lib/sqlalchemy/orm/persistence.py/_collect_post_update_commands