Re: 'sequence' table?

[prev] [thread] [next] [Date index for 2004/09/21]

From: Dave Howorth
Subject: Re: 'sequence' table?
Date: 10:14 on 21 Sep 2004
Tony Bowden wrote:
>>>>FWIW, I would prefer to call the table 'sequences' and the column 
>>>>'sequences_id', or better yet 'sequence_id'. But I can't!
>>Suppose I do. Then I'd like to say:
>>__PACKAGE__->has_a(sequence => 'Sequences');
>>so that I can say print $obj->sequence->length for example.
>>That isn't supported, but I'm not clear what a reasonable idiom is to 
>>get that effect.
> 
> You can't say that, as the first argument to has_a is your column, and
> you don't have a column called sequence.
> 
> You need to say
> 
> __PACKAGE__->has_a(sequence_id => 'Sequences');
> print $obj->sequence_id->length 
> 
> If you really want to have the method be sequence() then use
> accessor_name() to change it.

Good, I finally managed to explain it well enough that we're on the same 
page and you were able to give me the hint I needed :) Thanks!

>>Sorry, it's Class::DBI::Loader::Relationship that wants the names to be 
>>the same.
> I've never used that, and don't know anything about it. I'd suggest
> taking this up with the author of that, or, perhaps, not using it, and
> declaring the relationships another way.

As it's a CDBI::* module, I was hoping that somebody else on the CDBI 
list might know about it.  My first thought was to use a different 
module and I asked that question on the Maypole list but the feeling was 
that it was likely to be difficult to swap it out. I may re-examine that 
option.

>>Maypole calls Lingua::EN::Inflect::PL on the table name. According to 
>>LEI's docs "The results of passing a plural form are undefined (and 
>>unlikely to be correct)."
> Then, again, perhaps you should skip the magic, and do things by hand.

My reason for wanting some magic is that I'm prototyping and expect to 
have to keep changing things, so I'd have to do things by hand 
repeatedly, with accompanying risk of mistakes.

IMHO, the magic and the problems have a common origin. Namely having 
code that conflates the view with the model: extracting user interface 
text from database table and column names. Clearly, that can cause 
problems; it doesn't handle internationalisation gracefully, for one 
example. But the main alternatives I see involve one or both of 
splitting the information amongst multiple places that have to be kept 
reconciled and/or lots of configuration or resource files that have to 
be maintained. I don't know if anybody has any good experience with ways 
to deal with this?

Thanks again,
Dave

(message missing)

'sequence' table?
Dave Howorth 16:17 on 17 Sep 2004

Re: 'sequence' table?
Charles Bailey 20:26 on 17 Sep 2004

Re: 'sequence' table?
Allen Day 06:08 on 18 Sep 2004

Re: 'sequence' table?
Tony Bowden 07:40 on 18 Sep 2004

Re: 'sequence' table?
Dave Howorth 09:31 on 20 Sep 2004

Re: 'sequence' table?
Tony Bowden 10:04 on 20 Sep 2004

Re: 'sequence' table?
Dave Howorth 12:08 on 20 Sep 2004

Re: 'sequence' table?
Tony Bowden 16:44 on 20 Sep 2004

Re: 'sequence' table?
Dave Howorth 10:14 on 21 Sep 2004

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