| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package # hide from PAUSE |
|
2
|
|
|
|
|
|
|
DBIx::Class::CDBICompat::Retrieve; |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
794
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
70
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# even though fatalization has been proven over and over to be a universally |
|
7
|
|
|
|
|
|
|
# bad idea, this line has been part of the code from the beginning |
|
8
|
|
|
|
|
|
|
# leaving the compat layer as-is, something may in fact depend on that |
|
9
|
2
|
|
|
2
|
|
13
|
use warnings FATAL => 'all'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
80
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
10
|
use base 'DBIx::Class'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1188
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub retrieve { |
|
14
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
15
|
0
|
0
|
|
|
|
|
die "No args to retrieve" unless @_ > 0; |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my @cols = $self->primary_columns; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $query; |
|
20
|
0
|
0
|
|
|
|
|
if (ref $_[0] eq 'HASH') { |
|
|
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$query = { %{$_[0]} }; |
|
|
0
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
elsif (@_ == @cols) { |
|
24
|
0
|
|
|
|
|
|
$query = {}; |
|
25
|
0
|
|
|
|
|
|
@{$query}{@cols} = @_; |
|
|
0
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
else { |
|
28
|
0
|
|
|
|
|
|
$query = {@_}; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$query = $self->_build_query($query); |
|
32
|
0
|
|
|
|
|
|
$self->find($query); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub find_or_create { |
|
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
37
|
0
|
0
|
|
|
|
|
my $query = ref $_[0] eq 'HASH' ? shift : {@_}; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$query = $self->_build_query($query); |
|
40
|
0
|
|
|
|
|
|
$self->next::method($query); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# _build_query |
|
44
|
|
|
|
|
|
|
# |
|
45
|
|
|
|
|
|
|
# Build a query hash. Defaults to a no-op; ColumnCase overrides. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_query { |
|
48
|
0
|
|
|
0
|
|
|
my ($self, $query) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $query; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub retrieve_from_sql { |
|
54
|
0
|
|
|
0
|
0
|
|
my ($class, $cond, @rest) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$cond =~ s/^\s*WHERE//i; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Need to parse the SQL clauses after WHERE in reverse |
|
59
|
|
|
|
|
|
|
# order of appearance. |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my %attrs; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if( $cond =~ s/\bLIMIT\s+(\d+)\s*$//i ) { |
|
64
|
0
|
|
|
|
|
|
$attrs{rows} = $1; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ( $cond =~ s/\bORDER\s+BY\s+(.*)\s*$//i ) { |
|
68
|
0
|
|
|
|
|
|
$attrs{order_by} = $1; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if( $cond =~ s/\bGROUP\s+BY\s+(.*)\s*$//i ) { |
|
72
|
0
|
|
|
|
|
|
$attrs{group_by} = $1; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
return $class->search_literal($cond, @rest, ( %attrs ? \%attrs : () ) ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub construct { |
|
79
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
80
|
0
|
|
|
|
|
|
my $obj = $class->resultset_instance->new_result(@_); |
|
81
|
0
|
|
|
|
|
|
$obj->in_storage(1); |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return $obj; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
0
|
0
|
|
sub retrieve_all { shift->search } |
|
87
|
0
|
|
|
0
|
0
|
|
sub count_all { shift->count } |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub maximum_value_of { |
|
90
|
0
|
|
|
0
|
0
|
|
my($class, $col) = @_; |
|
91
|
0
|
|
|
|
|
|
return $class->resultset_instance->get_column($col)->max; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub minimum_value_of { |
|
95
|
0
|
|
|
0
|
0
|
|
my($class, $col) = @_; |
|
96
|
0
|
|
|
|
|
|
return $class->resultset_instance->get_column($col)->min; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |