From: David Kamholz Date: Tue, 14 Mar 2006 23:31:05 +0000 (+0000) Subject: weaken result_source in all resultsets X-Git-Tag: v0.06000~60^2~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bcd264195a5ab28e03232464f786c155524a12a9;p=dbsrgits%2FDBIx-Class.git weaken result_source in all resultsets --- diff --git a/Changes b/Changes index 4b3c02e..7e7d7d9 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,5 @@ Revision history for DBIx::Class + - weaken result_source in all resultsets 0.05999_03 2006-03-14 01:58:10 - has_many prefetch fixes diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 07ca30e..626e1f7 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -8,6 +8,7 @@ use overload fallback => 1; use Data::Page; use Storable; +use Scalar::Util qw/weaken/; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/AccessorGroup/); @@ -71,8 +72,9 @@ sub new { return $class->new_result(@_) if ref $class; my ($source, $attrs) = @_; - #use Data::Dumper; warn Dumper($attrs); + weaken $source; $attrs = Storable::dclone($attrs || {}); # { %{ $attrs || {} } }; + #use Data::Dumper; warn Dumper($attrs); my $alias = ($attrs->{alias} ||= 'me'); $attrs->{columns} ||= delete $attrs->{cols} if $attrs->{cols}; diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 1f6863a..4331a15 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -5,9 +5,7 @@ use warnings; use DBIx::Class::ResultSet; use Carp::Clan qw/^DBIx::Class/; - use Storable; -use Scalar::Util qw/weaken/; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/AccessorGroup/); @@ -634,11 +632,7 @@ sub resultset { my $self = shift; $self->throw_exception('resultset does not take any arguments. If you want another resultset, call it on the schema instead.') if scalar @_; return $self->{_resultset} if ref $self->{_resultset} eq $self->resultset_class; - return $self->{_resultset} = do { - my $rs = $self->resultset_class->new($self, $self->{resultset_attributes}); - weaken $rs->result_source; - $rs; - }; + return $self->{_resultset} = $self->resultset_class->new($self, $self->{resultset_attributes}); } =head2 throw_exception