From: Moritz Onken Date: Sat, 13 Mar 2010 12:37:40 +0000 (+0000) Subject: reverting 8995, was supposed to go to a branch X-Git-Tag: v0.08121~64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4a20f3890186caa8d1ac6f6ae7706a276972f9f;p=dbsrgits%2FDBIx-Class.git reverting 8995, was supposed to go to a branch --- diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index d62e325..f05eff7 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -73,11 +73,8 @@ sub insert { sub inflate_result { my ($class, @rest) = @_; - - # we don't want to inflate_result on new_result - return $rest[3] if(defined $rest[3] && Scalar::Util::blessed $rest[3]); - my $new = $class->next::method(@rest); + return $new if $new->nocache; if (my $key = $new->ID) { diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index cbe81d3..4247459 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1859,9 +1859,8 @@ sub new_result { -source_handle => $self->_source_handle, -result_source => $self->result_source, # DO NOT REMOVE THIS, REQUIRED ); - my $row = $self->result_class->new(\%new); - #return $row; - return $self->result_class->inflate_result($self->result_source, $row->{_column_data}, undef, $row); + + return $self->result_class->new(\%new); } # _merge_cond_with_data diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 1d3a7c6..2777114 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -1067,7 +1067,7 @@ sub store_column { =over -=item Arguments: $result_source, \%columndata, \%prefetcheddata, [$row] +=item Arguments: $result_source, \%columndata, \%prefetcheddata =item Returns: A Row object @@ -1088,9 +1088,8 @@ L, see L. =cut sub inflate_result { - my ($class, $source, $me, $prefetch, $row) = @_; - return $row if (defined $row && (Scalar::Util::blessed $row)); - + my ($class, $source, $me, $prefetch) = @_; + my ($source_handle) = $source; if ($source->isa('DBIx::Class::ResultSourceHandle')) { diff --git a/t/93single_accessor_object.t b/t/93single_accessor_object.t index 987b185..892e656 100644 --- a/t/93single_accessor_object.t +++ b/t/93single_accessor_object.t @@ -45,20 +45,20 @@ plan tests => 10; $schema = DBICTest->init_schema(); { - my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); - my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982, genreid => undef }); + my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); + my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982, genreid => undef }); - ok(!defined($cd->get_column('genreid')), 'genreid is NULL'); #no accessor was defined for this column - ok(!defined($cd->genre), 'genre accessor returns undef'); + ok(!defined($cd->get_column('genreid')), 'genreid is NULL'); #no accessor was defined for this column + ok(!defined($cd->genre), 'genre accessor returns undef'); } $schema = DBICTest->init_schema(); { - my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); - my $genre = $schema->resultset('Genre')->create({ genreid => 88, name => 'disco' }); - my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982 }); + my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); + my $genre = $schema->resultset('Genre')->create({ genreid => 88, name => 'disco' }); + my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982 }); - dies_ok { $cd->genre } 'genre accessor throws without column'; + dies_ok { $cd->genre } 'genre accessor throws without column'; } diff --git a/t/row/inflate_result.t b/t/row/inflate_result.t index 370c205..c31d804 100644 --- a/t/row/inflate_result.t +++ b/t/row/inflate_result.t @@ -2,7 +2,6 @@ package My::Schema::Result::User; use strict; use warnings; -use DBIx::Class::ResultClass::HashRefInflator; use base qw/DBIx::Class::Core/; ### Define what our admin class is, for ensure_class_loaded() @@ -21,7 +20,6 @@ __PACKAGE__->set_primary_key('user_id'); sub inflate_result { my $self = shift; my $ret = $self->next::method(@_); - if ( $ret->admin ) { ### If this is an admin, rebless for extra functions $self->ensure_class_loaded($admin_class); bless $ret, $admin_class; @@ -63,7 +61,6 @@ package main; use lib qw(t/lib); use DBICTest; -use DBIx::Class::ResultClass::HashRefInflator; use Test::More; @@ -87,12 +84,10 @@ ok( ) ); -my $rs = $schema->resultset('User'); - TODO: { local $TODO = 'New objects should also be inflated'; - my $user = $rs->create($user_data); - my $admin = $rs->create($admin_data); + my $user = $schema->resultset('User')->create($user_data); + my $admin = $schema->resultset('User')->create($admin_data); is( ref $user, 'My::Schema::Result::User' ); is( ref $admin, 'My::Schema::Result::User::Admin' );