line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::ResultSet::WindowFunctions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: (DEPRECATED) Add support for window functions to DBIx::Class |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
144861
|
use v5.14; |
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use parent 'DBIx::Class::Helper::WindowFunctions'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 'v0.4.0'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _resolved_attrs { |
14
|
4
|
|
|
4
|
|
650592
|
my $rs = $_[0]; |
15
|
4
|
|
|
|
|
12
|
my $attrs = $rs->{attrs}; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
26
|
my $sqla = $rs->result_source->storage->sql_maker; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
336
|
foreach my $attr (qw/ select +select /) { |
20
|
|
|
|
|
|
|
|
21
|
8
|
100
|
|
|
|
30
|
my $sel = $attrs->{$attr} or next; |
22
|
4
|
|
|
|
|
29
|
my @sel; |
23
|
|
|
|
|
|
|
|
24
|
4
|
50
|
|
|
|
10
|
foreach my $col ( @{ ref $sel eq 'ARRAY' ? $sel : [$sel] } ) { |
|
4
|
|
|
|
|
21
|
|
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
12
|
push @sel, $col; |
27
|
|
|
|
|
|
|
|
28
|
4
|
50
|
|
|
|
17
|
next unless ref $col eq 'HASH'; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
10
|
my $as = delete $col->{'-as'}; |
31
|
4
|
50
|
|
|
|
14
|
my $over = delete $col->{'-over'} or next; |
32
|
|
|
|
|
|
|
|
33
|
4
|
50
|
|
|
|
19
|
$rs->throw_exception('-over must be a hashref') |
34
|
|
|
|
|
|
|
unless ref $over eq 'HASH'; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
30
|
my ( $sql, @bind ) = $sqla->_recurse_fields($col); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my ( $part_sql, @part_bind ) = |
39
|
4
|
|
|
|
|
344
|
$sqla->_recurse_fields( $over->{partition_by} ); |
40
|
4
|
100
|
|
|
|
241
|
if ($part_sql) { |
41
|
3
|
|
|
|
|
12
|
$part_sql = $sqla->_sqlcase('partition by ') . $part_sql; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my ( $order_sql, @order_bind ) = |
45
|
4
|
|
|
|
|
34
|
$sqla->_order_by( $over->{order_by} ); |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
875
|
$sql .= $sqla->_sqlcase(' over (') . $part_sql . $order_sql . ')'; |
48
|
4
|
100
|
|
|
|
30
|
if ($as) { |
49
|
2
|
|
|
|
|
12
|
$sql .= $sqla->_sqlcase(' as ') . $sqla->_quote($as); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
62
|
push @bind, @part_bind, @order_bind; |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
21
|
$sel[-1] = \[ $sql, @bind ]; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
4
|
|
|
|
|
25
|
$attrs->{$attr} = \@sel; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
14
|
return $rs->next::method; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |