Hi, All.

I have found unexpected behaviour of MySQL DB. In update command order of
operations in set list is significant. I need to switch values of 2 rows.
Better see example:
mysql> create temporary table sw_test (a integer not null, b integer not
null, dummy integer);
Query OK, 0 rows affected (0.23 sec)

mysql> insert into sw_test (a, b) values (1, 2), (4, 3);
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> update sw_test set a=b, b=a where a<b;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from sw_test;
+---+---+-------+
| a | b | dummy |
+---+---+-------+
| 2 | 2 |  NULL |
| 4 | 3 |  NULL |
+---+---+-------+
2 rows in set (0.00 sec)

Here update lost values of one row... but if we write:
mysql> update sw_test set dummy=a, a=b, b=dummy, dummy=null where b<a;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from sw_test;
+---+---+-------+
| a | b | dummy |
+---+---+-------+
| 2 | 2 |  NULL |
| 3 | 4 |  NULL |
+---+---+-------+
2 rows in set (0.00 sec)

Very ugly but what else?

Is there a way to forse order of columns in SA update clause?

PS: mysql-5.1.56
sqlalchemt-0.6.7

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to