$new = $self->{class}->_row_to_object(\@cols, \@main);
PRE: foreach my $pre (@{$self->{attrs}{prefetch}}) {
my $rel_obj = $self->{class}->_relationships->{$pre};
- my @pre_cols = $rel_obj->{class}->columns;
+ my $pre_class = $self->{class}->resolve_class($rel_obj->{class});
+ my @pre_cols = $pre_class->_select_columns;
my @vals = splice(@row, 0, scalar @pre_cols);
- my $fetched = $rel_obj->{class}->_row_to_object(\@pre_cols, \@vals);
+ my $fetched = $pre_class->_row_to_object(\@pre_cols, \@vals);
$self->{class}->throw("No accessor for prefetched $pre")
unless defined $rel_obj->{attrs}{accessor};
if ($rel_obj->{attrs}{accessor} eq 'single') {
eval "use DBD::SQLite";
plan $@
? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 21 );
+ : ( tests => 22 );
}
# test the abstract join => SQL generator
is($cd[1]->{_relationship_data}{liner_notes}->notes, 'Buy Whiskey!', 'Prefetch for present LEFT JOIN');
+is(ref $cd[1]->liner_notes, 'DBICTest::LinerNotes', 'Prefetch returns correct class');
+
is($cd[2]->{_inflated_column}{artist}->name, 'Caterwauler McCrae', 'Prefetch on parent object ok');
# count the SELECTs