Module: tools Branch: master Commit: 2a350500f2075a7da7c0b8337772ede3b94978d6 URL: http://source.winehq.org/git/tools.git/?a=commit;h=2a350500f2075a7da7c0b8337... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Thu Jun 12 10:14:41 2014 +0200 testbot/lib: DBIBackend::LoadItem() must not return objects from the Collection scope. Such checks belong to the higher levels. Doing them in LoadItem() interferes with Collection::Validate(), causing it to think new items are already present in the database whenever they don't have Sequence keys. --- testbot/lib/ObjectModel/DBIBackEnd.pm | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/testbot/lib/ObjectModel/DBIBackEnd.pm b/testbot/lib/ObjectModel/DBIBackEnd.pm index c89fa64..06b139d 100644 --- a/testbot/lib/ObjectModel/DBIBackEnd.pm +++ b/testbot/lib/ObjectModel/DBIBackEnd.pm @@ -253,14 +253,24 @@ sub LoadCollection $Statement->finish(); } +=pod +=over 12 + +=item C<LoadItem()> + +Loads the specified Item from the database and adds it to the Collection. +By design this method will not check if the Item is already present in the +Collection scope. Such checks belong in the higher levels. This method will +however put the Item in the Collection's scope. + +=back +=cut + sub LoadItem { my $self = shift; my ($Collection, $RequestedKey) = @_; - my $Item = $Collection->GetScopeItem($RequestedKey); - return $Item if (defined $Item); - my $Fields = $self->BuildFieldList($Collection->GetPropertyDescriptors()); my $Where = ""; @@ -283,7 +293,7 @@ sub LoadItem my $Statement = $self->GetDb()->prepare($Query); $Statement->execute(@Data); - $Item = undef; + my $Item; if (my $Row = $Statement->fetchrow_hashref()) { $Item = $Collection->CreateItem();