| 861 | |
| 862 | @testing.fixture |
| 863 | def randomized_param_order_update(self): |
| 864 | from sqlalchemy.sql.dml import UpdateDMLState |
| 865 | |
| 866 | super_process_ordered_values = UpdateDMLState._process_ordered_values |
| 867 | |
| 868 | # this fixture is needed for Python 3.6 and above to work around |
| 869 | # dictionaries being insert-ordered. in python 2.7 the previous |
| 870 | # logic fails pretty easily without this fixture. |
| 871 | def _process_ordered_values(self, statement): |
| 872 | super_process_ordered_values(self, statement) |
| 873 | |
| 874 | tuples = list(self._dict_parameters.items()) |
| 875 | random.shuffle(tuples) |
| 876 | self._dict_parameters = dict(tuples) |
| 877 | |
| 878 | dialect = default.StrCompileDialect() |
| 879 | dialect.paramstyle = "qmark" |
| 880 | dialect.positional = True |
| 881 | |
| 882 | with mock.patch.object( |
| 883 | UpdateDMLState, "_process_ordered_values", _process_ordered_values |
| 884 | ): |
| 885 | yield |
| 886 | |
| 887 | def random_update_order_parameters(): |
| 888 | from sqlalchemy import ARRAY |