X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=7e59438a5026bdbe86410c2e5a978aaf6b4e01bf;hb=6bf3e3b3fa88b45f33ff21ae38239c69bd14335c;hp=5a6b98026f621dd2b860c0b7f85b1ffe15c108c4;hpb=af29cd123d78f75d4cc5b622925b7b2860d2d0b7;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 5a6b980..7e59438 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -660,7 +660,7 @@ L for more information. sub cursor { my ($self) = @_; - my $attrs = { %{$self->_resolved_attrs} }; + my $attrs = $self->_resolved_attrs_copy; return $self->{cursor} ||= $self->result_source->storage->select($attrs->{from}, $attrs->{select}, $attrs->{where},$attrs); @@ -711,7 +711,7 @@ sub single { $self->throw_exception('single() only takes search conditions, no attributes. You want ->search( $cond, $attrs )->single()'); } - my $attrs = { %{$self->_resolved_attrs} }; + my $attrs = $self->_resolved_attrs_copy; if ($where) { if (defined $attrs->{where}) { $attrs->{where} = { @@ -1157,13 +1157,13 @@ sub count { sub _count_subq { my $self = shift; - my $attrs = { %{$self->_resolved_attrs} }; + my $attrs = $self->_resolved_attrs_copy; # copy for the subquery, we need to do some adjustments to it too my $sub_attrs = { %$attrs }; - # these can not go in the subquery either - delete $sub_attrs->{$_} for qw/prefetch collapse select +select as +as columns +columns/; + # these can not go in the subquery, and there is no point of ordering it + delete $sub_attrs->{$_} for qw/prefetch collapse select +select as +as columns +columns order_by/; # force a group_by and the same set of columns (most databases require this) $sub_attrs->{columns} = $sub_attrs->{group_by} ||= [ map { "$attrs->{alias}.$_" } ($self->result_source->primary_columns) ]; @@ -1197,7 +1197,7 @@ sub _count_simple { sub __count { my ($self, $attrs) = @_; - $attrs ||= { %{$self->_resolved_attrs} }; + $attrs ||= $self->_resolved_attrs_copy; # take off any column specs, any pagers, record_filter is cdbi, and no point of ordering a count delete $attrs->{$_} for (qw/columns +columns select +select as +as rows offset page pager order_by record_filter/); @@ -1338,7 +1338,7 @@ sub _rs_update_delete { if ($needs_group_by_subq or $needs_subq) { # make a new $rs selecting only the PKs (that's all we really need) - my $attrs = $self->_resolved_attrs; + my $attrs = $self->_resolved_attrs_copy; delete $attrs->{$_} for qw/prefetch collapse select +select as +as columns +columns/; $attrs->{columns} = [ map { "$attrs->{alias}.$_" } ($self->result_source->primary_columns) ]; @@ -2496,6 +2496,12 @@ sub _resolve_from { return ($from,$seen); } +# too many times we have to do $attrs = { %{$self->_resolved_attrs} } +sub _resolved_attrs_copy { + my $self = shift; + return { %{$self->_resolved_attrs (@_)} }; +} + sub _resolved_attrs { my $self = shift; return $self->{_attrs} if $self->{_attrs};