line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
3
|
|
|
3
|
|
1729
|
use Moo::Role; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
22
|
|
4
|
3
|
|
|
3
|
|
632
|
use namespace::clean; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
22
|
|
5
|
3
|
|
|
3
|
|
1248
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
18
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.12"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'create_table'; |
9
|
|
|
|
|
|
|
requires 'add_row'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my ($self, $bag, $start, $limit, $where) = @_; |
12
|
|
|
|
|
|
|
my $id_field = $bag->mapping->{_id}->{column}; |
13
|
1
|
|
|
1
|
0
|
3
|
my $q_id_field = $bag->_quote_id($id_field); |
14
|
1
|
|
|
|
|
3
|
|
15
|
1
|
|
|
|
|
4
|
my $sql = "SELECT * FROM " . $bag->_quote_id($bag->name); |
16
|
|
|
|
|
|
|
$sql .= " WHERE $where" if $where; |
17
|
1
|
|
|
|
|
24
|
|
18
|
1
|
50
|
|
|
|
22
|
my $default_order = $bag->default_order // $bag->store->default_order; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
33
|
|
|
8
|
if (defined $default_order) { |
21
|
|
|
|
|
|
|
if ($default_order eq 'ID') { |
22
|
1
|
50
|
|
|
|
3
|
$sql .= " ORDER BY $q_id_field"; |
23
|
1
|
50
|
|
|
|
3
|
} |
|
|
0
|
|
|
|
|
|
24
|
1
|
|
|
|
|
3
|
elsif ($default_order eq 'NONE') { |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# no nothing |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
|
|
|
|
|
|
$sql .= " ORDER BY $default_order"; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
0
|
} |
32
|
|
|
|
|
|
|
$sql .= " LIMIT $limit OFFSET $start"; |
33
|
|
|
|
|
|
|
$sql; |
34
|
1
|
|
|
|
|
3
|
} |
35
|
1
|
|
|
|
|
5
|
|
36
|
|
|
|
|
|
|
my ($self, $bag, $start, $total, $where) = @_; |
37
|
|
|
|
|
|
|
my $name = $bag->name; |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
8
|
0
|
183
|
return "SELECT COUNT(*) FROM " . $bag->_quote_id($name) |
40
|
8
|
|
|
|
|
28
|
unless $total || $start || $where; |
41
|
|
|
|
|
|
|
|
42
|
8
|
100
|
100
|
|
|
72
|
my $sql = "SELECT COUNT(*) FROM (SELECT * FROM " . $bag->_quote_id($name); |
|
|
|
100
|
|
|
|
|
43
|
|
|
|
|
|
|
if ($where) { |
44
|
|
|
|
|
|
|
$sql .= " WHERE $where"; |
45
|
4
|
|
|
|
|
14
|
} |
46
|
4
|
100
|
|
|
|
106
|
if ($total) { |
47
|
3
|
|
|
|
|
8
|
$sql .= " LIMIT $total"; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
100
|
|
|
|
11
|
elsif ($start) { # no offset without limit |
|
|
100
|
|
|
|
|
|
50
|
2
|
|
|
|
|
8
|
$sql .= " LIMIT " . $bag->_max_limit; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
if ($start) { |
53
|
1
|
|
|
|
|
5
|
$sql .= " OFFSET $start"; |
54
|
|
|
|
|
|
|
} |
55
|
4
|
100
|
|
|
|
56
|
$sql .= ") AS q"; |
56
|
3
|
|
|
|
|
7
|
|
57
|
|
|
|
|
|
|
$sql; |
58
|
4
|
|
|
|
|
7
|
} |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
22
|
1; |
61
|
|
|
|
|
|
|
|