Re: Need help with finding solution to CDBI bug

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

From: William McKee
Subject: Re: Need help with finding solution to CDBI bug
Date: 13:19 on 22 Jun 2004
On Mon, Jun 21, 2004 at 11:16:30PM +0300, Yuval Kogman wrote:
> I think the simplest way is to represent a primary key with a
> stringifyable object. This eliminates the list vs. scalar context, etc,
> and ensures that data comming out of CDBI can be consistently fed back
> into it.

It seems that Tony and Tim agree with you. What did you think of Tim's
suggested solution.


> Stringification will give a logical value, and % deref should also be
> overloaded, to get column => value.

I'm not sure how % deref would be overloaded (I'm new to overloading).
Could you show an example through code? Where's the need for this?


> Then is it also consistent to return these objects from $obj->id?
> 
> 	my ($film, $actor) = $obj->id; # or is it ($actor, $film)?
> 	
> 	my %hash = $obj->id; # unambiguos, but not what we get right now
> 	my ($film, $actor) = @hash{qw/film actor/};

I'm not following the hash example since id() returns a scalar or an
array. I don't know what order the fields are returned in and would
guess that code should not rely on this order. From my tests, it
*appears* to be in the order that the primary keys are defined.


> My question really is:
> 
> 	is a foreign key the same as the primary key it references?

My hunch is yes due to inflation.


> in reality it is a copy, but it can be treated in funny ways by the
> database (cascading deletes, maybe triggers for various ops on a table
> acting on another table).

As shown by my DBD::Pg errors and your stringification problems. Any
other instances that you know of where this is causing errors?


> In CDBI, a foreign key is actually the row in the pointed table, which
> is logical because we're inflating. Is the primary key the row as well?
> can the ID be regarded as the object and vice versa? if so, why do we
> need ID, can't we just pass the objects? This is consistent, but
> limiting.

Well, the foreign key is an object inside of another class whereas the
primary key will be just that object.

  Class1->primary_key
  Class2->foreign_key->{Class1->primary_key}

For my needs, the id of the foreign_key needs to be stringified to a
scalar value when doing DBI ops. Otherwise, it's rather convenient that
I can call $class2->foreign_key->field_in_Class1.


> > This makes sense. Because you are stringifying, I can see where the
> > delete function which calls $self->id would pass in the stringified
> > version of the field instead of the id.
> 
> I guess it is sane in a way. But it's ambiguous, too.
> "John Cleese/Holy Grail" is pretty coherent, but that doesn't work
> everywhere.

This stringification would fail if passed to DBI since I need two
values, not one. For my needs, it's important that a multi-column
primary key be broken into individual keys that are stringified then
returned as an array.

I'm not sure at this point whether I'm addressing the questions you've
posed or simply babbling on incomprehensibly about things which I'm only
dimly beginning to understand <g>. Feel free to drop this thread or take
it off list to spare the sanity of others.

Regards,
William

        -- 
        Knowmad Services Inc.
http://www.knowmad.com

(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