return @args;
}
+ sub _resolve_ident_sources {
+ my ($self, $ident) = @_;
+
+ my $alias2source = {};
+
+ # the reason this is so contrived is that $ident may be a {from}
+ # structure, specifying multiple tables to join
+ if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ $alias2source->{$ident->alias} = $ident;
+ }
+ elsif (ref $ident eq 'ARRAY') {
+
+ for (@$ident) {
+ my $tabinfo;
+ if (ref $_ eq 'HASH') {
+ $tabinfo = $_;
+ }
+ if (ref $_ eq 'ARRAY' and ref $_->[0] eq 'HASH') {
+ $tabinfo = $_->[0];
+ }
+
+ $alias2source->{$tabinfo->{-alias}} = $tabinfo->{-result_source}
+ if ($tabinfo->{-result_source});
+ }
+ }
+
+ return $alias2source;
+ }
+
-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/select as rows offset page order_by record_filter/};
- my $tmp_attrs = { %$attrs };
+ return \%attrs;
+}
+
+sub count {
+ my ($self, $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);
# overwrite the selector
$tmp_attrs->{select} = { count => '*' };