| 1 | package SQL::Abstract::Pg; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use parent 'SQL::Abstract'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | BEGIN { *puke = \&SQL::Abstract::puke } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 15 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | my ($self, $table, $data, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 15 | ▶ | local @{$options}{qw(returning _pg_returning)} = (1, 1) if exists $options->{on_conflict} && !$options->{returning}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $options->{"on_conflict"} and not $options->{"returning"}
MC/DC100%2/2
exists $options->{"on_conflict"} and not $options->{"returning"}
exists $options->{"on_conflict"}
not $options->{"returning"}
Truth table100%3/3
A and not(B)
A= exists $options->{"on_conflict"}B= not $options->{"returning"}
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 15 | return $self->SUPER::insert($table, $data, $options); | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $self = shift->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # -json op | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | push @{$self->{unary_ops}}, { | |||||||||||||||||||||||||||||||||||||||||
| 24 | regex => qr/^json$/, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | handler => sub { '?', {json => $_[2]} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 15 | ▶ | sub _expand_insert_clause_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_insert_clause_from: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 15 | my ($self, undef, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | # Bulk insert (array of hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 35 | return $self->SUPER::_expand_insert_clause_from(undef, $data) | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 15 | ▶ | unless ref $data eq 'ARRAY' && ref $data->[0] eq 'HASH' && grep { !/^-/ } keys %{$data->[0]}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
ref $data eq "ARRAY" and ref $data->[0] eq "HASH" and grep {not /^-/;} keys %{$$data[0];}
ref $data eq "ARRAY" and ref $data->[0] eq "HASH"
MC/DC66%2/3
ref $data eq "ARRAY" and ref $data->[0] eq "HASH" and grep {not /^-/;} keys %{$$data[0];}
ref $data eq "ARRAY"
ref $data->[0] eq "HASH"
grep {not /^-/;} keys %{$$data[0];}
Truth table75%3/4
A and B and C
A= ref $data eq "ARRAY"B= ref $data->[0] eq "HASH"C= grep {not /^-/;} keys %{$$data[0];}
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | ▶ | puke 'bulk insert values must all be hash references' if grep { ref $_ ne 'HASH' } @$data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | my %fields = map { $_ => 1 } map { keys %$_ } @$data; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | my @fields = sort keys %fields; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | my @rows; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | for my $row (@$data) { | |||||||||||||||||||||||||||||||||||||||||
| 43 | push @rows, { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | -row => [ | ||||||||||||||||||||||||||||||||||||||||||
| 45 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 9 | local $SQL::Abstract::Cur_Col_Meta = $_; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | ▶ | exists $row->{$_} ? $self->_expand_insert_value($row->{$_}) : {-keyword => 'default'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | } @fields | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | return (from => {-values => \@rows}, fields => $self->expand_expr({-row => \@fields}, -ident)); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | sub _insert_returning { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_insert_returning: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | my ($self, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 9 | ▶ | delete $options->{returning} if $options->{_pg_returning}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # ON CONFLICT | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 9 | my $sql = ''; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | my @bind; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | ▶ | if (exists $options->{on_conflict}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 9 | my $conflict = $options->{on_conflict}; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 9 | my ($conflict_sql, @conflict_bind); | |||||||||||||||||||||||||||||||||||||||||
| 67 | $self->_SWITCH_refkind( | ||||||||||||||||||||||||||||||||||||||||||
| 68 | $conflict => { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | ARRAYREF => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my ($target, $set) = @$conflict; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | puke 'on_conflict value must be in the form [$target, \%set]' unless ref $set eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | $target = [$target] unless ref $target eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | $conflict_sql = '(' . join(', ', map { $self->_quote($_) } @$target) . ')'; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | $conflict_sql .= $self->_sqlcase(' do update set '); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | my ($set_sql, @set_bind) = $self->_update_set_values($set); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | $conflict_sql .= $set_sql; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | push @conflict_bind, @set_bind; | |||||||||||||||||||||||||||||||||||||||||
| 79 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | ARRAYREFREF => sub { ($conflict_sql, @conflict_bind) = @$$conflict }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | SCALARREF => sub { $conflict_sql = $$conflict }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | UNDEF => sub { $conflict_sql = $self->_sqlcase('do nothing') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | $sql .= $self->_sqlcase(' on conflict ') . $conflict_sql; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | push @bind, @conflict_bind; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | ▶ | $sql .= $self->SUPER::_insert_returning($options) if $options->{returning}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | return $sql, @bind; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 13 | ▶ | sub _order_by { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_order_by: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 13 | my ($self, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # Legacy | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 13 | ▶ | return $self->SUPER::_order_by($options) if ref $options ne 'HASH' or grep {/^-(?:desc|asc)/i} keys %$options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $options ne "HASH" or grep {/^-(?:desc|asc)/i;} keys %$options
MC/DC50%1/2
ref $options ne "HASH" or grep {/^-(?:desc|asc)/i;} keys %$options
ref $options ne "HASH"
grep {/^-(?:desc|asc)/i;} keys %$options
Truth table66%2/3
A or B
A= ref $options ne "HASH"B= grep {/^-(?:desc|asc)/i;} keys %$options
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # GROUP BY | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 11 | my $sql = ''; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 11 | my @bind; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 11 | ▶ | if (defined(my $group = $options->{group_by})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | my $group_sql; | |||||||||||||||||||||||||||||||||||||||||
| 105 | $self->_SWITCH_refkind( | ||||||||||||||||||||||||||||||||||||||||||
| 106 | $group => { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | ARRAYREF => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | $group_sql = join ', ', map { $self->_quote($_) } @$group; | |||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | SCALARREF => sub { $group_sql = $$group } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | $sql .= $self->_sqlcase(' group by ') . $group_sql; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # HAVING | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 10 | ▶ | if (defined(my $having = $options->{having})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | my ($having_sql, @having_bind) = $self->_recurse_where($having); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $sql .= $self->_sqlcase(' having ') . $having_sql; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | push @bind, @having_bind; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # ORDER BY | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 10 | ▶ | $sql .= $self->_order_by($options->{order_by}) if defined $options->{order_by}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | # LIMIT | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 10 | ▶ | if (defined $options->{limit}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $sql .= $self->_sqlcase(' limit ') . '?'; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | push @bind, $options->{limit}; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | # OFFSET | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 10 | ▶ | if (defined $options->{offset}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | $sql .= $self->_sqlcase(' offset ') . '?'; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | push @bind, $options->{offset}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # FOR | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | ▶ | if (defined(my $for = $options->{for})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | my $for_sql; | |||||||||||||||||||||||||||||||||||||||||
| 141 | $self->_SWITCH_refkind( | ||||||||||||||||||||||||||||||||||||||||||
| 142 | $for => { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | SCALAR => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | puke qq{for value "$for" is not allowed} unless $for eq 'update'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | $for_sql = $self->_sqlcase('UPDATE'); | |||||||||||||||||||||||||||||||||||||||||
| 146 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | SCALARREF => sub { $for_sql .= $$for } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | $sql .= $self->_sqlcase(' for ') . $for_sql; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 8 | return $sql, @bind; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 27 | ▶ | sub _select_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_select_fields: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 27 | my ($self, $fields) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 27 | ▶ | return $fields unless ref $fields eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | my (@fields, @bind); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 4 | for my $field (@$fields) { | |||||||||||||||||||||||||||||||||||||||||
| 163 | $self->_SWITCH_refkind( | ||||||||||||||||||||||||||||||||||||||||||
| 164 | $field => { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | ARRAYREF => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | puke 'field alias must be in the form [$name => $alias]' if @$field < 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | push @fields, $self->_quote($field->[0]) . $self->_sqlcase(' as ') . $self->_quote($field->[1]); | |||||||||||||||||||||||||||||||||||||||||
| 168 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | ARRAYREFREF => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | push @fields, shift @$$field; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | push @bind, @$$field; | |||||||||||||||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ▶ | SCALARREF => sub { push @fields, $$field }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | ▶ | FALLBACK => sub { push @fields, $self->_quote($field) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | return join(', ', @fields), @bind; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 28 | ▶ | sub _table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 28 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 28 | ▶ | return $self->SUPER::_table($table) unless ref $table eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 10 | my (@table, @join); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 10 | for my $t (@$table) { | |||||||||||||||||||||||||||||||||||||||||
| 189 | 22 | ▶ | if (ref $t eq 'ARRAY') { push @join, $t } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | else { push @table, $t } | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 10 | $table = $self->SUPER::_table(\@table); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 10 | ▶ | my $sep = $self->{name_sep} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"name_sep"} // ""
MC/DC0%0/1
$self->{"name_sep"} // ""
$self->{"name_sep"}
Truth table50%1/2
A
A= $self->{"name_sep"}
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 10 | for my $join (@join) { | |||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | ▶ | puke 'join must be in the form [$table, $fk => $pk]' if @$join < 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | ▶ | my ($type, $name, $fk, $pk, @morekeys) = @$join % 2 == 0 ? @$join : ('', @$join); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 9 | ▶ | $table | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | .= $self->_sqlcase($type =~ /^-(.+)$/ ? " $1 join " : ' join ') | ||||||||||||||||||||||||||||||||||||||||||
| 200 | . $self->_quote($name) | ||||||||||||||||||||||||||||||||||||||||||
| 201 | . $self->_sqlcase(' on ') . '('; | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 9 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 12 | ▶ | $table | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | .= $self->_quote(index($fk, $sep) > 0 ? $fk : "$name.$fk") . ' = ' | ||||||||||||||||||||||||||||||||||||||||||
| 205 | . $self->_quote(index($pk, $sep) > 0 ? $pk : "$table[0].$pk") | ||||||||||||||||||||||||||||||||||||||||||
| 206 | . (@morekeys ? $self->_sqlcase(' and ') : ')'); | ||||||||||||||||||||||||||||||||||||||||||
| 207 | } while ($fk, $pk, @morekeys) = @morekeys; | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 9 | return $table; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | SQL::Abstract::Pg - PostgreSQL features for SQL::Abstract | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | use SQL::Abstract::Pg; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | my $abstract = SQL::Abstract::Pg->new; | ||||||||||||||||||||||||||||||||||||||||||
| 226 | say $abstract->select('some_table'); | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | L<SQL::Abstract::Pg> extends L<SQL::Abstract> with a few PostgreSQL features used by L<Mojo::Pg>. | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | =head2 JSON | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | In many places (as supported by L<SQL::Abstract>) you can use the C<-json> unary op to encode JSON from Perl data | ||||||||||||||||||||||||||||||||||||||||||
| 235 | structures. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | # "UPDATE some_table SET foo = '[1,2,3]' WHERE bar = 23" | ||||||||||||||||||||||||||||||||||||||||||
| 238 | $abstract->update('some_table', {foo => {-json => [1, 2, 3]}}, {bar => 23}); | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | # "SELECT * FROM some_table WHERE foo = '[1,2,3]'" | ||||||||||||||||||||||||||||||||||||||||||
| 241 | $abstract->select('some_table', '*', {foo => {'=' => {-json => [1, 2, 3]}}}); | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | =head1 INSERT | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | $abstract->insert($table, \@values || \%fieldvals || \@fieldvals, \%options); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | =head2 BULK INSERT | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | The C<$data> argument now also accepts array references containing hash references, to generate C<INSERT> queries | ||||||||||||||||||||||||||||||||||||||||||
| 250 | with multiple rows. Fields missing from some rows will be set to C<DEFAULT>. Keep in mind that PostgreSQL limits the | ||||||||||||||||||||||||||||||||||||||||||
| 251 | number of bind values per query to 65535, so very large inserts need to be split up. | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | # "INSERT INTO t (a, b) VALUES ('c', 'd'), ('e', DEFAULT)" | ||||||||||||||||||||||||||||||||||||||||||
| 254 | $abstract->insert('t', [{a => 'c', b => 'd'}, {a => 'e'}]); | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # "INSERT INTO t (a) VALUES ('b'), ('c') ON CONFLICT DO NOTHING RETURNING id" | ||||||||||||||||||||||||||||||||||||||||||
| 257 | $abstract->insert('t', [{a => 'b'}, {a => 'c'}], {on_conflict => undef, returning => 'id'}); | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 ON CONFLICT | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | The C<on_conflict> option can be used to generate C<INSERT> queries with C<ON CONFLICT> clauses. So far, C<undef> to | ||||||||||||||||||||||||||||||||||||||||||
| 262 | pass C<DO NOTHING>, array references to pass C<DO UPDATE> with conflict targets and a C<SET> expression, scalar | ||||||||||||||||||||||||||||||||||||||||||
| 263 | references to pass literal SQL and array reference references to pass literal SQL with bind values are supported. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | # "INSERT INTO t (a) VALUES ('b') ON CONFLICT DO NOTHING" | ||||||||||||||||||||||||||||||||||||||||||
| 266 | $abstract->insert('t', {a => 'b'}, {on_conflict => undef}); | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # "INSERT INTO t (a) VALUES ('b') ON CONFLICT DO NOTHING" | ||||||||||||||||||||||||||||||||||||||||||
| 269 | $abstract->insert('t', {a => 'b'}, {on_conflict => \'do nothing'}); | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | This includes operations commonly referred to as C<upsert>. | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | # "INSERT INTO t (a) VALUES ('b') ON CONFLICT (a) DO UPDATE SET a = 'c'" | ||||||||||||||||||||||||||||||||||||||||||
| 274 | $abstract->insert('t', {a => 'b'}, {on_conflict => [a => {a => 'c'}]}); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | # "INSERT INTO t (a, b) VALUES ('c', 'd') ON CONFLICT (a, b) DO UPDATE SET a = 'e'" | ||||||||||||||||||||||||||||||||||||||||||
| 277 | $abstract->insert('t', {a => 'c', b => 'd'}, {on_conflict => [['a', 'b'] => {a => 'e'}]}); | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | # "INSERT INTO t (a) VALUES ('b') ON CONFLICT (a) DO UPDATE SET a = 'c'" | ||||||||||||||||||||||||||||||||||||||||||
| 280 | $abstract->insert('t', {a => 'b'}, {on_conflict => \['(a) do update set a = ?', 'c']}); | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =head1 SELECT | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | $abstract->select($source, $fields, $where, $order); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | $abstract->select($source, $fields, $where, \%options); | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | =head2 AS | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | The C<$fields> argument now also accepts array references containing array references with field names and aliases, as | ||||||||||||||||||||||||||||||||||||||||||
| 290 | well as array references containing scalar references to pass literal SQL and array reference references to pass | ||||||||||||||||||||||||||||||||||||||||||
| 291 | literal SQL with bind values. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | # "SELECT foo AS bar FROM some_table" | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $abstract->select('some_table', [[foo => 'bar']]); | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | # "SELECT foo, bar AS baz, yada FROM some_table" | ||||||||||||||||||||||||||||||||||||||||||
| 297 | $abstract->select('some_table', ['foo', [bar => 'baz'], 'yada']); | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | # "SELECT EXTRACT(EPOCH FROM foo) AS foo, bar FROM some_table" | ||||||||||||||||||||||||||||||||||||||||||
| 300 | $abstract->select('some_table', [\'extract(epoch from foo) AS foo', 'bar']); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | # "SELECT 'test' AS foo, bar FROM some_table" | ||||||||||||||||||||||||||||||||||||||||||
| 303 | $abstract->select('some_table', [\['? AS foo', 'test'], 'bar']); | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =head2 JOIN | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | The C<$source> argument now also accepts array references containing not only table names, but also array references | ||||||||||||||||||||||||||||||||||||||||||
| 308 | with tables to generate C<JOIN> clauses for. | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | # "SELECT * FROM foo JOIN bar ON (bar.foo_id = foo.id)" | ||||||||||||||||||||||||||||||||||||||||||
| 311 | $abstract->select(['foo', ['bar', foo_id => 'id']]); | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | # "SELECT * FROM foo JOIN bar ON (foo.id = bar.foo_id)" | ||||||||||||||||||||||||||||||||||||||||||
| 314 | $abstract->select(['foo', ['bar', 'foo.id' => 'bar.foo_id']]); | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | # "SELECT * FROM a JOIN b ON (b.a_id = a.id) JOIN c ON (c.a_id = a.id)" | ||||||||||||||||||||||||||||||||||||||||||
| 317 | $abstract->select(['a', ['b', a_id => 'id'], ['c', a_id => 'id']]); | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | # "SELECT * FROM foo LEFT JOIN bar ON (bar.foo_id = foo.id)" | ||||||||||||||||||||||||||||||||||||||||||
| 320 | $abstract->select(['foo', [-left => 'bar', foo_id => 'id']]); | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | # "SELECT * FROM a LEFT JOIN b ON (b.a_id = a.id AND b.a_id2 = a.id2)" | ||||||||||||||||||||||||||||||||||||||||||
| 323 | $abstract->select(['a', [-left => 'b', a_id => 'id', a_id2 => 'id2']]); | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | =head2 ORDER BY | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | Alternatively to the C<$order> argument accepted by L<SQL::Abstract> you can now also pass a hash reference with | ||||||||||||||||||||||||||||||||||||||||||
| 328 | various options. This includes C<order_by>, which takes the same values as the C<$order> argument. | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # "SELECT * FROM some_table ORDER BY foo DESC" | ||||||||||||||||||||||||||||||||||||||||||
| 331 | $abstract->select('some_table', '*', undef, {order_by => {-desc => 'foo'}}); | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | =head2 LIMIT/OFFSET | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | The C<limit> and C<offset> options can be used to generate C<SELECT> queries with C<LIMIT> and C<OFFSET> clauses. | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | # "SELECT * FROM some_table LIMIT 10" | ||||||||||||||||||||||||||||||||||||||||||
| 338 | $abstract->select('some_table', '*', undef, {limit => 10}); | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | # "SELECT * FROM some_table OFFSET 5" | ||||||||||||||||||||||||||||||||||||||||||
| 341 | $abstract->select('some_table', '*', undef, {offset => 5}); | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | # "SELECT * FROM some_table LIMIT 10 OFFSET 5" | ||||||||||||||||||||||||||||||||||||||||||
| 344 | $abstract->select('some_table', '*', undef, {limit => 10, offset => 5}); | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | =head2 GROUP BY | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | The C<group_by> option can be used to generate C<SELECT> queries with C<GROUP BY> clauses. So far, array references to | ||||||||||||||||||||||||||||||||||||||||||
| 349 | pass a list of fields and scalar references to pass literal SQL are supported. | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | # "SELECT * FROM some_table GROUP BY foo, bar" | ||||||||||||||||||||||||||||||||||||||||||
| 352 | $abstract->select('some_table', '*', undef, {group_by => ['foo', 'bar']}); | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | # "SELECT * FROM some_table GROUP BY foo, bar" | ||||||||||||||||||||||||||||||||||||||||||
| 355 | $abstract->select('some_table', '*', undef, {group_by => \'foo, bar'}); | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =head2 HAVING | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | The C<having> option can be used to generate C<SELECT> queries with C<HAVING> clauses, which takes the same values as | ||||||||||||||||||||||||||||||||||||||||||
| 360 | the C<$where> argument. | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | # "SELECT * FROM t GROUP BY a HAVING b = 'c'" | ||||||||||||||||||||||||||||||||||||||||||
| 363 | $abstract->select('t', '*', undef, {group_by => ['a'], having => {b => 'c'}}); | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | =head2 FOR | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | The C<for> option can be used to generate C<SELECT> queries with C<FOR> clauses. So far, the scalar value C<update> to | ||||||||||||||||||||||||||||||||||||||||||
| 368 | pass C<UPDATE> and scalar references to pass literal SQL are supported. | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # "SELECT * FROM some_table FOR UPDATE" | ||||||||||||||||||||||||||||||||||||||||||
| 371 | $abstract->select('some_table', '*', undef, {for => 'update'}); | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | # "SELECT * FROM some_table FOR UPDATE SKIP LOCKED" | ||||||||||||||||||||||||||||||||||||||||||
| 374 | $abstract->select('some_table', '*', undef, {for => \'update skip locked'}); | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | L<SQL::Abstract::Pg> inherits all methods from L<SQL::Abstract>. | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | Sebastian Riedel, C<sri@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | Copyright (C) 2014-2021, Sebastian Riedel and others. | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 2.0. | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | L<https://github.com/mojolicious/sql-abstract-pg>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | =cut | ||||||||||||||||||||||||||||||||||||||||||