X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=52cd45619381f4833cbb67866e02a74bbeb45b29;hb=70f524e6b39efe4fb16e2fd75132c118f050df25;hp=c9f816e6e9d7dda64757c6b7641851afa76b485d;hpb=9117ccfbf28509b84d895508334d758a5ed84718;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index c9f816e..52cd456 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -958,6 +958,22 @@ sub _fix_bind_params { } @bind; } +sub _flatten_bind_params { + my ($self, @bind) = @_; + + ### Turn @bind from something like this: + ### ( [ "artist", 1 ], [ "cdid", 1, 3 ] ) + ### to this: + ### ( 1, 1, 3 ) + return + map { + if ( defined( $_ && $_->[1] ) ) { + @{$_}[ 1 .. $#$_ ]; + } + else { undef; } + } @bind; +} + sub _query_start { my ( $self, $sql, @bind ) = @_; @@ -1308,13 +1324,20 @@ sub _resolve_ident_sources { 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 => '*' };