db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kostya <kos...@ifit.uni-klu.ac.at>
Subject [PATCH] Update contains more then one table in where clause
Date Thu, 11 Mar 2004 14:30:50 GMT
Hi All!
Originally this question was raised by Daniel Larsson, who had a problem with doUpdate that
has in were clause more then 
one table needed to select records for update. I've tried to help him, but have found that
BasePeer.doUpdate cannot 
handle queries like this one (mysql style):
update book, author  set title = 'Updated title' where book.author_id=author.author_id AND
author.name='Author 3';

For the given example the main loop of doUpdate will be executed twice. On the first execution
a where clause of a 
dataset will be an empty String and all records in book table will be updated (misbehavior).
On the second execution the 
where clause will be "author.name='Author 3'" and when a dataset will be fetched it will try
to update book.title fields 

The attached patch corrects this method. It will select prior all primary keys of an updated
table that identify records 
to be updated. These keys will be used in where clause to select a dataset.
Patch and test are attached.


View raw message