Skip to content

Commit fa26eba

Browse files
committed
Improve logic in PostgresVersion.pm
Handle the situation where perl swaps the order of operands of the comparison operator. See `perldoc overload` for details: The third argument is set to TRUE if (and only if) the two operands have been swapped. Perl may do this to ensure that the first argument ($self) is an object implementing the overloaded operation, in line with general object calling conventions.
1 parent 0c8f408 commit fa26eba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/perl/PostgresVersion.pm

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ sub new
110110
#
111111
sub _version_cmp
112112
{
113-
my ($a, $b) = @_;
113+
my ($a, $b, $swapped) = @_;
114114

115115
$b = __PACKAGE__->new($b) unless blessed($b);
116116

117+
($a, $b) = ($b, $a) if $swapped;
118+
117119
my ($an, $bn) = ($a->{num}, $b->{num});
118120

119121
for (my $idx = 0;; $idx++)

0 commit comments

Comments
 (0)