From: Peter Rabbitson Date: Mon, 1 Mar 2010 17:04:19 +0000 (+0000) Subject: Add has_relationship proxy to row X-Git-Tag: v0.08121~96 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0818c9a7335e4843136e62496099dec7ceea7dae;p=dbsrgits%2FDBIx-Class.git Add has_relationship proxy to row --- diff --git a/Changes b/Changes index 529fe7f..1ab1a7b 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for DBIx::Class - Fix regression on not properly throwing when $obj->relationship is unresolvable + - Add has_relationship method to row objects 0.08120 2010-02-24 08:58:00 (UTC) - Make sure possibly overwritten deployment_statements methods in diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index bc36bbb..2a71a98 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -260,6 +260,8 @@ dkubb: Dan Kubb dnm: Justin Wheeler +dpetrov: Dimitar Petrov + dwc: Daniel Westermann-Clark dyfrgi: Michael Leuchtenburg diff --git a/lib/DBIx/Class/ResultSourceProxy.pm b/lib/DBIx/Class/ResultSourceProxy.pm index 6df208e..6af0202 100644 --- a/lib/DBIx/Class/ResultSourceProxy.pm +++ b/lib/DBIx/Class/ResultSourceProxy.pm @@ -110,4 +110,7 @@ sub relationship_info { shift->result_source_instance->relationship_info(@_); } +sub has_relationship { + shift->result_source_instance->has_relationship(@_); +} 1; diff --git a/t/relationship/core.t b/t/relationship/core.t index 62776fa..720ca26 100644 --- a/t/relationship/core.t +++ b/t/relationship/core.t @@ -79,6 +79,10 @@ my $track = $schema->resultset("Track")->create( { } ); $track->set_from_related( cd => $cd ); +# has_relationship +ok(! $track->has_relationship( 'foo' ), 'Track has no relationship "foo"'); +ok($track->has_relationship( 'disc' ), 'Track has relationship "disk"' ); + is($track->disc->cdid, 4, 'set_from_related ok, including alternative accessor' ); $track->set_from_related( cd => undef );