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

    update = []
    for state, state_dict, mapper, connection in states_to_update:
        if table not in mapper._pks_by_table:
            continue
        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)

            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:
            update.append((state, state_dict, params, mapper,
                           connection))
    return update
Identify sets of values to use in UPDATE statements for a
dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py/_collect_post_update_commands