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) {
-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
=over
-=item Arguments: $result_source, \%columndata, \%prefetcheddata, [$row]
+=item Arguments: $result_source, \%columndata, \%prefetcheddata
=item Returns: A Row object
=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')) {
$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';
}
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()
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;
use lib qw(t/lib);
use DBICTest;
-use DBIx::Class::ResultClass::HashRefInflator;
use Test::More;
)
);
-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' );