From: Rafael Kitover Date: Sat, 6 Jun 2009 02:45:09 +0000 (+0000) Subject: Merge 'trunk' into 'sybase' X-Git-Tag: v0.08112~14^2~144 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d1ec2830cc15412c0a99d77b97dc95393af1e66a;p=dbsrgits%2FDBIx-Class.git Merge 'trunk' into 'sybase' r5351@hlagh (orig r6518): ribasushi | 2009-06-05 07:28:58 -0700 This was dumb - of course I want a copy Otherwise the next serach_related will work with a contaminated seen_joins r5353@hlagh (orig r6520): ribasushi | 2009-06-05 10:25:56 -0700 Factor out the grouped count subquery SELECTor so specific storage classes can override it Trim attribute deletion lists - we work with _resolved_attrs - +X are already folded into X and the like --- d1ec2830cc15412c0a99d77b97dc95393af1e66a diff --cc lib/DBIx/Class/Storage/DBI.pm index cee87a7,89b9096..20b1f1f --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@@ -1245,27 -1229,18 +1245,25 @@@ sub _select_args 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