The UPDATE question of raw SQL has SET clause. It is rendered by way of the replace() assemble the use of the column ordering given in the originating Table item. Therefore, a selected UPDATE statement with precise columns could be rendered the identical each time. Since the parameters themselves are passed to the Update.Values() approach as Python dictionary keys, there may be no different fixed ordering to be had.
In a few cases, the order of parameters rendered inside the SET clause are tremendous. In MySQL, supplying updates to column values is based totally on that of other column values.
Following statement’s result −
UPDATE table1 SET x = y + 10, y = 20
can have a distinctive end result than −
UPDATE table1 SET y = 20, x = y + 10
SET clause in MySQL is evaluated on a in step with-fee basis and now not on in line with-row basis. For this cause, the preserve_parameter_order is used. Python list of two-tuples is given as argument to the Update.Values() approach −
stmt = table1.update(preserve_parameter_order = True).\
values([(table1.c.y, 20), (table1.c.x, table1.c.y + 10)])
The List object is much like dictionary except that it's miles ordered. This guarantees that the “y” column’s SET clause will render first, then the “x” column’s SET clause.