Module: tools Branch: master Commit: 50477068bc2a067180f1484bd923d2b6e972f8f4 URL: https://source.winehq.org/git/tools.git/?a=commit;h=50477068bc2a067180f1484b...
Author: Francois Gouget fgouget@codeweavers.com Date: Sat Apr 21 20:02:58 2018 +0200
testbot: Check $Item->{IsNew} before $Item->{IsModified}.
After creating a new item one normally modifies a number of fields. So check whether the item is new before assuming we simply need to update it just because IsModified is true.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/lib/ObjectModel/DBIBackEnd.pm | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/testbot/lib/ObjectModel/DBIBackEnd.pm b/testbot/lib/ObjectModel/DBIBackEnd.pm index 40bfe85..ec1b450 100644 --- a/testbot/lib/ObjectModel/DBIBackEnd.pm +++ b/testbot/lib/ObjectModel/DBIBackEnd.pm @@ -515,26 +515,18 @@ sub SaveItem($$) { my ($self, $Item) = @_;
- my $Query; - my ($MasterColNames, $MasterColValues) = $Item->GetMasterCols(); - if ($Item->GetIsModified()) - { - $Query = $self->BuildUpdateStatement($Item->GetTableName(), - $Item->GetPropertyDescriptors(), - $MasterColNames); - } - elsif ($Item->GetIsNew()) + if ($Item->GetIsNew()) { die "Internal error: Need to save new items via collection"; } - else - { - return; - } + if (!$Item->GetIsModified());
+ my ($MasterColNames, $MasterColValues) = $Item->GetMasterCols(); + my $Query = $self->BuildUpdateStatement($Item->GetTableName(), + $Item->GetPropertyDescriptors(), + $MasterColNames); my $Statement = $self->GetDb()->prepare($Query); $Statement->execute(@{$self->GetUpdateData($MasterColValues, $Item)}); - $Statement->finish(); }