Subject: | Unable to handle multiple primary keys |
Date: | Thu, 26 Aug 2010 12:21:16 -0400 |
To: | bug-Catalyst-Controller-DBIC-API [...] rt.cpan.org |
From: | Jon Gentle <jgentle [...] safeschools.com> |
We are working on using DBIC::API to create a REST API, and we have a
couple tables that have a multiple column primary key. The data is
completely inaccessible from the DBIC::API since a single column primary
key is assumed. I have worked around the problem by making a quick and
dirty patch to object_lookup (below), but I doubt that is the proper
solution. The version that is installed is 2.002001.
Thanks.
-Jon Gentle
---
--- a/lib/perl5/Catalyst/Controller/DBIC/API.pm
+++ b/lib/perl5/Catalyst/Controller/DBIC/API.pm
@@ -210,7 +210,8 @@ sub object_lookup
my ($self, $c, $id) = @_;
die 'No valid ID provided for look up' unless defined $id and
length $id;
- my $object = $c->req->current_result_set->find($id);
+ my @id = split /::/, $id;
+ my $object = $c->req->current_result_set->find(@id);
die "No object found for id '$id'" unless defined $object;
return $object;
}