Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e8d89f

Browse files
committed
Add PostgresVersion.pm method to emit the major version string
For versions before 10, this will produce dotted notation unless aseparator argument is given, in which case it is used.
1 parent5dc932f commit1e8d89f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎src/test/perl/PostgresVersion.pm‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ PostgresVersion - class representing PostgreSQL version numbers
3232
# interpolate in a string
3333
my $stringyval = "version: $version";
3434
35+
# get the major version
36+
my $maj = $version->major;
37+
3538
=head1DESCRIPTION
3639
3740
PostgresVersion encapsulates Postgres version numbers, providing parsing
@@ -133,4 +136,29 @@ sub _stringify
133136
return$self->{str};
134137
}
135138

139+
=pod
140+
141+
=over
142+
143+
=itemmajor([separator => 'char'])
144+
145+
Returns the major version. For versions before 10 the parts are separated by
146+
a dot unless the separator argument is given.
147+
148+
=back
149+
150+
=cut
151+
152+
submajor
153+
{
154+
my ($self,%params) =@_;
155+
my$result =$self->{num}->[0];
156+
if ($result + 0 < 10)
157+
{
158+
my$sep =$params{separator} ||'.';
159+
$result .="$sep$self->{num}->[1]";
160+
}
161+
return$result;
162+
}
163+
136164
1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp