line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1771
|
use 5.20.0; |
|
2
|
|
|
|
|
9
|
|
2
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
32
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DBIx::Class::Smooth::ResultSetBase; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Short intro |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.0102'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
10
|
use parent 'DBIx::Class::ResultSet'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
12
|
2
|
|
|
2
|
|
152
|
use List::SomeUtils qw/any/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
13
|
2
|
|
|
2
|
|
728
|
use Safe::Isa qw/$_isa/; |
|
2
|
|
|
|
|
833
|
|
|
2
|
|
|
|
|
181
|
|
14
|
2
|
|
|
2
|
|
12
|
use Carp qw/croak confess/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
15
|
2
|
|
|
2
|
|
710
|
use DBIx::Class::Smooth::Q; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
11
|
|
16
|
2
|
|
|
2
|
|
1041
|
use DBIx::Class::Smooth::FilterItem; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
66
|
|
17
|
2
|
|
|
2
|
|
14
|
use experimental qw/signatures postderef/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
|
|
sub _smooth__prepare_for_filter($self, @args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @qobjs = grep { $_->$_isa('DBIx::Class::Smooth::Q') } @args; |
|
0
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if(scalar @qobjs) { |
22
|
0
|
0
|
|
|
|
|
if(scalar @args > 1) { |
23
|
0
|
|
|
|
|
|
die "Don't mix Q() and normal args"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
0
|
|
|
|
|
|
@args = $args[0]->value->@*; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $i = undef; |
31
|
0
|
|
|
|
|
|
my $prepared_args = []; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
ARG: |
34
|
0
|
|
|
|
|
|
for my $fori (0..scalar @args - 1) { |
35
|
|
|
|
|
|
|
# We do it this way since not all search args are key => value pairs (such as \[] searches) |
36
|
|
|
|
|
|
|
# meaning that sometimes we need to $i += 1 and sometimes $i += 2 |
37
|
0
|
0
|
|
|
|
|
$i = $fori if !defined $i; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $possible_key = $args[$i]; |
40
|
0
|
0
|
|
|
|
|
my $possible_value = $i + 1 <= scalar @args - 1 ? $args[$i + 1] : undef; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Dig deeper into the search structure |
43
|
0
|
0
|
0
|
0
|
|
|
if($possible_value && any { $possible_key eq $_ } (qw/-and -or -not_bool/)) { |
|
0
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if(ref $possible_value eq 'ARRAY') { |
45
|
0
|
|
|
|
|
|
push $prepared_args->@* => ($possible_key => $self->_smooth__prepare_for_filter($possible_value->@*)); |
46
|
0
|
|
|
|
|
|
$i += 2; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
|
|
|
|
|
|
# There is no $possible_value for \[] searches, the value is already in the arrayrefref |
51
|
0
|
0
|
0
|
|
|
|
if(ref $possible_key eq 'REF') { |
|
|
0
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
push $prepared_args->@* => $possible_key; |
53
|
0
|
|
|
|
|
|
$i++; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif(defined $possible_key && defined $possible_value) { |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my @key_parts = split /__/ => $possible_key; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $item = DBIx::Class::Smooth::FilterItem->new(resultset => $self, parts => \@key_parts, value => $possible_value); |
60
|
0
|
|
|
|
|
|
($possible_key, $possible_value) = $item->parse; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if($possible_key) { |
63
|
0
|
|
|
|
|
|
push $prepared_args->@* => ($possible_key, $possible_value); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
0
|
|
|
|
|
|
push $prepared_args->@* => $possible_value; |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
$i += 2; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
|
return $prepared_args; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
0
|
|
sub filter($self, @args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# only compatible with array and Q |
77
|
0
|
|
|
|
|
|
my $args = $self->_smooth__prepare_for_filter(-and => \@args); |
78
|
0
|
|
|
|
|
|
return $self->search($args); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
0
|
|
sub filterattr($self, %args) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $self->search({}, \%args); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
DBIx::Class::Smooth::ResultSetBase - Short intro |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Version 0.0102, released 2019-12-22. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SOURCE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-DBIx-Class-Smooth> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 HOMEPAGE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<https://metacpan.org/release/DBIx-Class-Smooth> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Erik Carlsson. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
118
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |