Module: tools Branch: master Commit: 4a9e60c2ce8626b618241663d3fd697d155857a8 URL: https://source.winehq.org/git/tools.git/?a=commit;h=4a9e60c2ce8626b618241663...
Author: Francois Gouget fgouget@codeweavers.com Date: Fri Jun 3 19:22:51 2022 +0200
testbot/orm: Fix multi-column key support in Item::Compare().
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/lib/ObjectModel/Item.pm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/testbot/lib/ObjectModel/Item.pm b/testbot/lib/ObjectModel/Item.pm index 7d36ffa..0b1da92 100644 --- a/testbot/lib/ObjectModel/Item.pm +++ b/testbot/lib/ObjectModel/Item.pm @@ -422,22 +422,27 @@ sub Compare($$) { my $ColName = $ColNames->[0]; my $ColType = $PropertyDescriptor->GetType(); - return ($ColType eq "N" or $ColType eq "S" or $ColType eq "DT") ? - $self->{ColValues}{$ColName} <=> $B->{ColValues}{$ColName} : - $self->{ColValues}{$ColName} cmp $B->{ColValues}{$ColName}; + my $Cmp = ($ColType eq "N" or $ColType eq "S" or $ColType eq "DT") ? + $self->{ColValues}{$ColName} <=> $B->{ColValues}{$ColName} : + $self->{ColValues}{$ColName} cmp $B->{ColValues}{$ColName}; + return $Cmp if ($Cmp); } - if ($PropertyDescriptor->GetClass() eq "Enum") + elsif ($PropertyDescriptor->GetClass() eq "Enum") { my $ColName = $ColNames->[0]; - return $self->{ColValues}{$ColName} cmp $B->{ColValues}{$ColName}; - } - - # A Detailref cannot be a key so this is an Itemref - foreach my $ColName (@$ColNames) - { my $Cmp = $self->{ColValues}{$ColName} cmp $B->{ColValues}{$ColName}; return $Cmp if ($Cmp); } + else + { + # A Detailref cannot be a key so this is an Itemref. Note that its + # underlying column types are unknown so treat them as strings. + foreach my $ColName (@$ColNames) + { + my $Cmp = $self->{ColValues}{$ColName} cmp $B->{ColValues}{$ColName}; + return $Cmp if ($Cmp); + } + } } return 0; }