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
|
|
163812
|
use v5.10; |
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
553
|
use parent 'DBIx::Class::Helper::WindowFunctions'; |
|
1
|
|
|
|
|
388
|
|
|
1
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 'v0.3.0'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _resolved_attrs { |
16
|
4
|
|
|
4
|
|
668971
|
my $rs = $_[0]; |
17
|
4
|
|
|
|
|
14
|
my $attrs = $rs->{attrs}; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
31
|
my $sqla = $rs->result_source->storage->sql_maker; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
387
|
foreach my $attr (qw/ select +select /) { |
22
|
|
|
|
|
|
|
|
23
|
8
|
100
|
|
|
|
36
|
my $sel = $attrs->{$attr} or next; |
24
|
4
|
|
|
|
|
10
|
my @sel; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
11
|
foreach my $col ( @{ ref $sel eq 'ARRAY' ? $sel : [$sel] } ) { |
|
4
|
|
|
|
|
22
|
|
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
14
|
push @sel, $col; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
|
|
|
20
|
next unless ref $col eq 'HASH'; |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
13
|
my $as = delete $col->{'-as'}; |
33
|
4
|
50
|
|
|
|
15
|
my $over = delete $col->{'-over'} or next; |
34
|
|
|
|
|
|
|
|
35
|
4
|
50
|
|
|
|
15
|
$rs->throw_exception('-over must be a hashref') |
36
|
|
|
|
|
|
|
unless ref $over eq 'HASH'; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
34
|
my ( $sql, @bind ) = $sqla->_recurse_fields($col); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ( $part_sql, @part_bind ) = |
41
|
4
|
|
|
|
|
398
|
$sqla->_recurse_fields( $over->{partition_by} ); |
42
|
4
|
100
|
|
|
|
217
|
if ($part_sql) { |
43
|
3
|
|
|
|
|
11
|
$part_sql = $sqla->_sqlcase('partition by ') . $part_sql; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ( $order_sql, @order_bind ) = |
47
|
4
|
|
|
|
|
40
|
$sqla->_order_by( $over->{order_by} ); |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
963
|
$sql .= $sqla->_sqlcase(' over (') . $part_sql . $order_sql . ')'; |
50
|
4
|
100
|
|
|
|
36
|
if ($as) { |
51
|
2
|
|
|
|
|
6
|
$sql .= $sqla->_sqlcase(' as ') . $sqla->_quote($as); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
60
|
push @bind, @part_bind, @order_bind; |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
24
|
$sel[-1] = \[ $sql, @bind ]; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
19
|
$attrs->{$attr} = \@sel; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
14
|
return $rs->next::method; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |