Re: Need help with finding solution to CDBI bug

[prev] [thread] [next] [Date index for 2004/06/25]

From: Takes Tea at Half Past Three
Subject: Re: Need help with finding solution to CDBI bug
Date: 17:06 on 25 Jun 2004
Charles Bailey said:
>I hope that helps explain the confusion to which I keep referring. 
>To summarize briefly: It seems to me that deciding id() (as a public 
>object method) should return only the SQL-level PK breaks the 
>encapsulation CDBI is trying to create, and is only in service of 
>internal use, for which case another function which is aware of CBDI 
><-> DBI internals would suffice.

I agree that id() is pretty tied to the DB (and maybe should have 
been named something like _id), but why would you expect it to not 
be? Where are you using id() that it makes sense that it returns 
something other than whatever the DB uses to identify the object?

It makes sense to me that id() returns something that *identifies* an 
object, rather than something that *is* an object. I don't expect to 
be able to call $cd->id->title.

Even if I have a table like liner_notes, which might use an FK as its 
PK, I expect to write something like $liner_notes->cd->title, not 
$liner_notes->id->title;

Incidentally, is the definition of Music::LinerNotes missing from the docs?


>I'd favor a scheme in which id() was the object-level PK, and 
>db_id() or somesuch was the flattened PK value, but if I'm way off 
>on the fringe, and most people have historically understood id() to 
>refer to the flat PK (as opposed to not even considering the 
>difference), then I'd suggest as an alternative that id() be so 
>documented, and a new method, such as key() or obj_id(), be 
>introduced to return the object-level PK.

Can't you get the object version of your PK by calling the field by its name?

Here's the original example from this thread:

   package QT::DBI::Groups;
   use base qw(QT::DBI);
   __PACKAGE__->table('groups');
   __PACKAGE__->columns(Primary => qw/grp user_id/);
   __PACKAGE__->has_a(user_id => 'QT::DBI::Users');

   package QT::DBI::Users;
   use base qw(QT::DBI);
   __PACKAGE__->table('users');
   __PACKAGE__->columns(All => qw/user_id type_id reseller_id password 
credit_score ctime/);


If you want to get the user from a $group, you call $group->user_id, 
not $group->id. If you want to get the grp, you call $group->grp.

The case I can see that would cause a problem is when you have an 
inflated PK, and it happens to be named 'id'. Perhaps that's a case 
for renaming (via accessor_name?)?


        -- 
        Aneel Nazareth -- http://eye-of-newt.com/nazareth --

(message missing)

Need help with finding solution to CDBI bug
William McKee 11:40 on 19 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 13:19 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 14:06 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 15:14 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 15:23 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 17:07 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 15:30 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 15:37 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 16:12 on 25 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 16:33 on 25 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 21:47 on 25 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 08:34 on 26 Jun 2004

Re: Need help with finding solution to CDBI bug
Takes Tea at Half Past Three 17:06 on 25 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 22:13 on 25 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 00:10 on 26 Jun 2004

RE: Need help with finding solution to CDBI bug
robert_creager 04:34 on 03 Jul 2004

Re: Need help with finding solution to CDBI bug
William McKee 17:17 on 05 Jul 2004

Re: Need help with finding solution to CDBI bug
Robert Creager 20:57 on 05 Jul 2004

Re: Need help with finding solution to CDBI bug
Robert Creager 00:22 on 06 Jul 2004

Re: Need help with finding solution to CDBI bug
William McKee 12:50 on 06 Jul 2004

Re: Need help with finding solution to CDBI bug
William McKee 17:05 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 17:18 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 17:41 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 18:04 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 19:20 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 20:16 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 07:34 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 14:25 on 21 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 20:03 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 22:44 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 15:16 on 24 Oct 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 22:15 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 12:33 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 17:17 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 11:38 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
merlyn (Randal L. Schwartz) 16:10 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 13:19 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 22:04 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 12:43 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 19:52 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 19:56 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 12:48 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 22:12 on 23 Jun 2004

Re: Need help with finding solution to CDBI bug
Yuval Kogman 23:30 on 22 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 07:08 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 13:53 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 14:51 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 07:12 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 13:50 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 14:55 on 24 Jun 2004

Re: Need help with finding solution to CDBI bug
Tony Bowden 16:04 on 27 Jun 2004

Re: Need help with finding solution to CDBI bug
Charles Bailey 17:53 on 27 Jun 2004

Re: Need help with finding solution to CDBI bug
William McKee 12:58 on 06 Jul 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52