$self->throw_exception( "new_result needs a hash" )
unless (ref $values eq 'HASH');
$self->throw_exception(
+ "Implicit construct invalid, condition was not resolveable on parent "
+ ."object"
+ ) if (defined $self->{cond}
+ && $self->{cond} eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION);
+ $self->throw_exception(
"Can't abstract implicit construct, condition not a hash"
) if ($self->{cond} && !(ref $self->{cond} eq 'HASH'));
=cut
+our $UNRESOLVABLE_CONDITION = \'1 = 0';
+
sub resolve_condition {
my ($self, $cond, $as, $for) = @_;
#warn %$cond;
if ($for->in_storage) {
$self->throw_exception("Column ${v} not loaded on ${for} trying to reolve relationship");
}
- return [ \'1 = 0' ];
+ return [ $UNRESOLVABLE_CONDITION ];
}
$ret{$k} = $for->get_column($v);
#$ret{$k} = $for->get_column($v) if $for->has_column_loaded($v);
my $schema = DBICTest->init_schema();
-plan tests => 63;
+plan tests => 64;
# has_a test
my $cd = $schema->resultset("CD")->find(4);
cmp_ok($artist->cds->count, '==', 0, "Correct new #cds for artist");
cmp_ok($nartist->cds->count, '==', 2, "Correct new #cds for artist");
+my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' });
+# why must i tell him: make a new related from me and me is me? that works!
+# my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982, 'artist' => $new_artist });
+my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave in Silence', 'year' => 1982});
+eval {
+ $new_artist->insert;
+ $new_related_cd->insert;
+};
+$@ && diag($@);
+ok($new_related_cd->in_storage, 'new_related_cd insert ok');