return @args;
}
-sub count {
+sub _trim_attributes_for_count {
my ($self, $source, $attrs) = @_;
+ my %attrs = %$attrs;
+
+ # take off any column specs, any pagers, record_filter is cdbi, and no point of ordering a count
- delete @attrs{qw/
- columns +columns select +select as +as rows offset page pager order_by
- record_filter/};
++ delete @attrs{qw/select as rows offset page order_by record_filter/};
- my $tmp_attrs = { %$attrs };
+ return \%attrs;
+}
+
+sub count {
+ my ($self, $source, $attrs) = @_;
- my $new_attrs = $self->_trim_attributes_for_count($source, $attrs);
- # take off any pagers, record_filter is cdbi, and no point of ordering a count
- delete $tmp_attrs->{$_} for (qw/select as rows offset page order_by record_filter/);
++ my $tmp_attrs = $self->_trim_attributes_for_count($source, $attrs);
- $new_attrs->{select} = { count => '*' };
- $new_attrs->{as} = [qw/count/];
+ # overwrite the selector
+ $tmp_attrs->{select} = { count => '*' };
- my $tmp_rs = $source->resultset_class->new($source, $new_attrs);
+ my $tmp_rs = $source->resultset_class->new($source, $tmp_attrs);
my ($count) = $tmp_rs->cursor->next;
# if the offset/rows attributes are still present, we did not use