X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FInterfaceModel%2FReflector%2FDBIC.pm;h=2c34cdf0c9602bfbf102a6c9b3eb07ff4f7b590a;hb=4949e0ee7a1162bca838822095e6cd2da527e2d2;hp=120ddb19dd2480efcf68a3b4e05d9ef6ceb2c6fa;hpb=2e99390063c9dc46cf295e7e0b56e286f01f6ddc;p=catagits%2FReaction.git diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm index 120ddb1..2c34cdf 100644 --- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm +++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm @@ -676,7 +676,10 @@ class DBIC, which { #default options. lazy build but no outsider method my %attr_opts = ( is => 'ro', lazy => 1, required => 1, clearer => "_clear_${attr_name}", - predicate => "has_${attr_name}", + predicate => { + "has_${attr_name}" => + sub { defined(shift->$dm_name->$attr_name) } + }, domain_model => $dm_name, orig_attr_name => $attr_name, ); @@ -706,8 +709,11 @@ class DBIC, which { #type constraint is the foreign IM object, default inflates it $attr_opts{isa} = $self->class_name_from_source_name($parent_class, $rel_moniker); $attr_opts{default} = sub { - shift->$dm_name - ->find_related($attr_name, {},{result_class => $attr_opts{isa}}); + if (defined(my $o = shift->$dm_name->$attr_name)) { + return $attr_opts{isa}->inflate_result($o->result_source, { $o->get_columns }); + } + return undef; + #->find_related($attr_name, {},{result_class => $attr_opts{isa}}); }; } } elsif( $constraint_is_ArrayRef && $attr_name =~ m/^(.*)_list$/ ) {