You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by kostya <ko...@ifit.uni-klu.ac.at> on 2004/03/11 15:30:50 UTC

[PATCH] Update contains more then one table in where clause

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 
(exception).

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.

Regards,
Kostya