[Catalyst] RFC: Catalyst::Controller::REST::DBIC

Matt S Trout dbix-class at trout.me.uk
Mon May 5 12:31:48 BST 2008

On Sun, May 04, 2008 at 09:06:30AM -0700, J. Shirley wrote:
> On Sun, May 4, 2008 at 8:52 AM, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> >
> >  Sorry but I don't understand your point - so maybe first I'll restate
> >  mine.  If you have primary key in the database that is of type varchar
> >  (or char or ...) then 'create' is a legitimage value for that primary
> >  key.
> >
> >  If you just don't like the string 'id' in the URI - then I have not
> >  any preference to that - it can be /foo/primary_key/ for me.
> >
> My point is that you do not have to use the primary key as the record
> lookup identifier.
> A user has no control over the record lookup identifier (ID) when you
> do things like /user/{primary_key} (or /user/id/{primary_key}, which
> is just converting named params to positional in a weird way).  In a
> lot of cases, the record lookup identifier makes more sense to be
> somewhat bound to the user.  As an example, lets say registering for a
> web service where you have to have a unique login:
>     POST /user/jshirley
>     ---
>     login: jshirley
>     first_name: Jay
>     last_name: Shirley
>     ...
> Now, it's a simple check here - does /user/jshirley exist?  If so,
> reject the request appropriately.  If not, create the user at
> /user/jshirley.
> The primary key that the database uses is completely useless to the
> user.  /user/1634254 is silly, /user/jshirley is meaningful.

I fail to see how whether the PK is the lookup key or not has any
relevance at all to the original point, which was "your lookup key and
names of actions might clash so it can be nice to have an extra path component
such as 'id' for the lookup part to disambiguate".

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

More information about the Catalyst mailing list