reverting 8995, was supposed to go to a branch
Moritz Onken [Sat, 13 Mar 2010 12:37:40 +0000 (12:37 +0000)]
lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/Row.pm
t/93single_accessor_object.t
t/row/inflate_result.t

index d62e325..f05eff7 100644 (file)
@@ -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) {
index cbe81d3..4247459 100644 (file)
@@ -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
index 1d3a7c6..2777114 100644 (file)
@@ -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<DBIx::Class::ResultSet>, see L<DBIx::Class::ResultSet/result_class>.
 =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')) {
index 987b185..892e656 100644 (file)
@@ -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';
 }
 
index 370c205..c31d804 100644 (file)
@@ -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' );