Re: Cross between MightHave and HasMany?

[prev] [thread] [next] [Date index for 2004/11/05]

From: Jess Robinson
Subject: Re: Cross between MightHave and HasMany?
Date: 20:06 on 05 Nov 2004
On Fri, 5 Nov 2004 09:21:45 -0500, William McKee <william@xxxxxxx.xxx>  
wrote:

> On Tue, Nov 02, 2004 at 02:06:45PM -0800, Peter Speltz wrote:
>> But if you want , Have you tried making a Temp column of person  
>> category? I
>> haven't tried Temp but from reading the docs, i hope to be able to say:
>>
>> Person->columns( Temp => [ "category"]);
>> Person->has_a(category => "PersonCategory");
>>
>> .... then  have everything work just like if the category column was in  
>> the
>> person table.  It should be able to update the PersonCategory object.

Oops, oversaw this suggestion. I've not tried it, but it sounds like I'd  
get the PersonCategory object, and not the Category object, when getting  
that. It would be nice if has_a worked 'via' another table too, like  
has_many does.

> Wouldn't using might_have provide the same results with less code?
>
> e.g.
>
>   Person->might_have(category => "PersonCategory" => qw/cat_id/);
>
> This brings up the question of whether CDBI makes category into a Temp
> column. Tony?

This presumably has the same drawback as the suggestion above. If I have  
to fetch the PC object, and from that get the Category object, I might as  
well go write the SQL..

>
>> .... then  have everything work just like if the category column was in  
>> the
>> person table.  It should be able to update the PersonCategory object.
>>
>> prsn_obj->category->cat_id($cgi_val);
>> prsn_obj->update; # or maybe prsn_obj->category->update;
>
> I would think that the prsn_obj->category->update would be the correct
> call. Personally, I wouldn't use this setup with a M2M relation. To get
> a category name, you'd need to use something like:
>
>   prsn_obj->category->category;
>
> Or stringify Category to the category column (which potentially
> introduces other weirdness).
>

Yup, isnt it all fun. Would be nice if there was a clear cut way to do  
one-to-one relationships. I'd write a new C::B::Relationship class if I  
could make any sense of them.

Jess


        -- 
        Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

(message missing)

Cross between MightHave and HasMany?
Jess Robinson 19:47 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Kingsley Kerce 20:08 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Jess Robinson 21:20 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Kingsley Kerce 21:35 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Jess Robinson 22:09 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Tony Bowden 23:43 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Peter Speltz 22:06 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Kingsley Kerce 22:39 on 02 Nov 2004

Re: Cross between MightHave and HasMany?
Jess Robinson 06:35 on 03 Nov 2004

Re: Cross between MightHave and HasMany?
William McKee 14:21 on 05 Nov 2004

Re: Cross between MightHave and HasMany?
Peter Speltz 14:36 on 05 Nov 2004

Re: Cross between MightHave and HasMany?
Jess Robinson 20:06 on 05 Nov 2004

Re: Cross between MightHave and HasMany?
William McKee 03:34 on 06 Nov 2004

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