William Ross will at spanner.org
Thu Nov 10 18:17:11 GMT 2005

On 10 Nov 2005, at 17:10, Steven Mackenzie wrote:

> William Ross wrote:
>> if I read this correctly, the more orthodox solution would be to
> :-)

That was prim, wasn't it? I'm sorry.

>> include a 'writer' column in the CD (or more likely Genre) class and
>> define a has_a relationship on that column that inflates to the
>> appropriate Writer object and deflates back to whatever arbitrary tag
>> you're using to identify it. Then you don't have to worry about
>> uniqueness and destruction at all.
> Neat. But in my case it would need to be a temporary column, as my
> choice of writer might not actually be related to anything stored  
> in the
> DB.

not a great fit, then. But I often find after some headbanging that  
there is a data class somewhere that maps onto the criteria I'm  
using, or perhaps some combination of factors like user preferences,  
object characteristics or environment variables can be used. The  
inflation method can take all that into account.

> Can I create a temporary column and inflate that with a has_a?

Good question. I don't see why not. Functionally it isn't much  
different to storing arbitrary keys in the object hash, so you may  
still have to deal with there being more than one instance of an  
object, but it ought to be more robust between versions and easier to  
follow. Also, i vaguely remember TB saying that cdbi might not always  
be a nice simple hash on the inside.


More information about the ClassDBI mailing list