X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FBase.pm;h=1853db37756f5ef8e7240abfa8af4e5d3e908dce;hb=1115a4219b76d4ac212fb91f24ff33e3f95b4e88;hp=3d0b44ca27a0915a5ab10185acea021b4da37e1e;hpb=7689b9e5b93232a57cbc49de64667317804cd3f6;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 3d0b44c..1853db3 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -567,6 +567,20 @@ in L for details. sub create_related { my $self = shift; my $rel = shift; + + # we need to stop and check if this is at all possible. If this is + # an extended relationship with an incomplete definition, we should + # just forbid it right now. + my $rel_info = $self->result_source->relationship_info($rel); + if (ref $rel_info->{cond} eq 'CODE') { + my ($cond, $ext) = $rel_info->{cond}->({ self_alias => 'me', + foreign_alias => 'other', + self_rowobj => $self + }); + $self->throw_exception("unable to set_from_related - no simplified condition available for '${rel}'") + unless $ext; + } + my $obj = $self->search_related($rel)->create(@_); delete $self->{related_resultsets}->{$rel}; return $obj;