From: David Kamholz Date: Thu, 23 Nov 2006 21:39:33 +0000 (+0000) Subject: - nuke old _resultset caching stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b051e1428d7d5b5b5c8c02874266e76546758f3;p=dbsrgits%2FDBIx-Class-Historic.git - nuke old _resultset caching stuff - teeny cleanup to ResultSetColumn code --- diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 49b8456..876a3c1 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -35,12 +35,8 @@ passed as params. Used internally by L. sub new { my ($class, $rs, $column) = @_; $class = ref $class if ref $class; - - my $object_ref = { _column => $column, - _parent_resultset => $rs }; - - my $new = bless $object_ref, $class; - $new->throw_exception("column must be supplied") unless ($column); + my $new = bless { _column => $column, _parent_resultset => $rs }, $class; + $new->throw_exception("column must be supplied") unless $column; return $new; } @@ -64,7 +60,6 @@ one value. sub next { my $self = shift; - $self->{_resultset} = $self->{_parent_resultset}->search(undef, {select => [$self->{_column}], as => [$self->{_column}]}) unless ($self->{_resultset}); my ($row) = $self->{_resultset}->cursor->next; return $row; @@ -111,8 +106,7 @@ resultset (or C if there are none). =cut sub min { - my $self = shift; - return $self->func('MIN'); + return shift->func('MIN'); } =head2 max @@ -133,8 +127,7 @@ resultset (or C if there are none). =cut sub max { - my $self = shift; - return $self->func('MAX'); + return shift->func('MAX'); } =head2 sum @@ -155,8 +148,7 @@ the resultset. Use on varchar-like columns at your own risk. =cut sub sum { - my $self = shift; - return $self->func('SUM'); + return shift->func('SUM'); } =head2 func @@ -180,9 +172,7 @@ value. Produces the following SQL: =cut sub func { - my $self = shift; - my $function = shift; - + my ($self,$function) = @_; my ($row) = $self->{_parent_resultset}->search(undef, {select => {$function => $self->{_column}}, as => [$self->{_column}]})->cursor->next; return $row; } diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 8cc5b6c..d89454a 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -46,9 +46,7 @@ sub new { my ($class, $attrs) = @_; $class = ref $class if ref $class; - my $new = { %{$attrs || {}}, _resultset => undef }; - bless $new, $class; - + my $new = bless { %{$attrs || {}} }, $class; $new->{resultset_class} ||= 'DBIx::Class::ResultSet'; $new->{resultset_attributes} = { %{$new->{resultset_attributes} || {}} }; $new->{_ordered_columns} = [ @{$new->{_ordered_columns}||[]}]; @@ -968,12 +966,6 @@ sub resultset { 'call it on the schema instead.' ) if scalar @_; - # disabled until we can figure out a way to do it without consistency issues - # - #return $self->{_resultset} - # if ref $self->{_resultset} eq $self->resultset_class; - #return $self->{_resultset} = - return $self->resultset_class->new( $self, $self->{resultset_attributes} );