Add has_relationship proxy to row
Peter Rabbitson [Mon, 1 Mar 2010 17:04:19 +0000 (17:04 +0000)]
Changes
lib/DBIx/Class.pm
lib/DBIx/Class/ResultSourceProxy.pm
t/relationship/core.t

diff --git a/Changes b/Changes
index 529fe7f..1ab1a7b 100644 (file)
--- 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
index bc36bbb..2a71a98 100644 (file)
@@ -260,6 +260,8 @@ dkubb: Dan Kubb <dan.kubb-cpan@onautopilot.com>
 
 dnm: Justin Wheeler <jwheeler@datademons.com>
 
+dpetrov: Dimitar Petrov <mitakaa@gmail.com>
+
 dwc: Daniel Westermann-Clark <danieltwc@cpan.org>
 
 dyfrgi: Michael Leuchtenburg <michael@slashhome.org>
index 6df208e..6af0202 100644 (file)
@@ -110,4 +110,7 @@ sub relationship_info {
   shift->result_source_instance->relationship_info(@_);
 }
 
+sub has_relationship {
+  shift->result_source_instance->has_relationship(@_);
+}
 1;
index 62776fa..720ca26 100644 (file)
@@ -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 );