File Coverage

blib/lib/DBIx/Romani/Query/Function/Count.pm
Criterion Covered Total %
statement 12 36 33.3
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 10 40.0
pod 0 6 0.0
total 16 59 27.1


line stmt bran cond sub pod time code
1              
2             package DBIx::Romani::Query::Function::Count;
3 1     1   5 use base qw(DBIx::Romani::Query::Function);
  1         2  
  1         107  
4              
5 1     1   6 use DBIx::Romani::Query::SQL::Column;
  1         2  
  1         20  
6 1     1   5 use DBIx::Romani::Query::SQL::Literal;
  1         3  
  1         18  
7 1     1   5 use strict;
  1         1  
  1         450  
8              
9             sub new
10             {
11 0     0 0   my $class = shift;
12 0           my $args = shift;
13              
14 0           my $distinct = 0;
15            
16 0 0         if ( ref($args) eq 'HASH' )
17             {
18 0   0       $distinct = $args->{distinct} || $distinct;
19             }
20            
21 0           my $self = $class->SUPER::new();
22 0           $self->{distinct} = $distinct;
23              
24 0           bless $self, $class;
25 0           return $self;
26             }
27              
28 0     0 0   sub get_distinct { return shift->{distinct}; }
29              
30             sub set_distinct
31             {
32 0     0 0   my ($self, $distinct) = @_;
33 0           $self->{distinct} = $distinct;
34             }
35              
36             sub add
37             {
38 0     0 0   my ($self, $value) = @_;
39            
40 0 0         if ( scalar @{$self->get_arguments()} == 1 )
  0            
41             {
42 0           die "Cannot set more than one argument for the COUNT function";
43             }
44              
45 0           $self->SUPER::add( $value );
46             }
47              
48             sub visit
49             {
50 0     0 0   my ($self, $visitor) = @_;
51 0           return $visitor->visit_function_count( $self );
52             }
53              
54             sub clone
55             {
56 0     0 0   my $self = shift;
57              
58 0           my $add;
59 0           $add = DBIx::Romani::Query::Function::Count->new({ distinct => $self->get_distinct() });
60 0           $add->copy_arguments( $self );
61              
62 0           return $add;
63             }
64              
65             1;
66