Re: [Maypole] 2.05 bug in Maypole::View::Base?

From: Dave Howorth (Dave.Howorth at acm.org)
Date: Thu Dec 30 2004 - 01:36:12 GMT


Tony Bowden wrote:
> On Wed, Dec 29, 2004 at 02:58:58PM -0800, Peter Speltz wrote:
>> I'm getting the "can't fetch data as class method error. If
>> description is a reserved word somewhere in Maypole, CDBI , or sql
>> or a bad choice of column names, i'll change my column name but i'm
>> not aware of it.
>
> It's not reserved in CDBI or SQL, so it must be Maypole.

description is a Maypole method. It's an optional model method that can
result in 'A poorly defined class' if you don't override it. See
Maypole::Model::Base.pm

> And having to change column names is a bad thing.

Absolutely! but that doesn't seem to apply when CDBI has already
overidden it at some time in the past or for some database I don't care
about ... e.g. sequence, or primary, or ...

I believe the only complete solution is to separate the namespaces.
Either all column-name methods should have a prefix (e.g. col_primary)
or all non-column-name methods should have a prefix (e.g.
cdbi_retrieve). Or just possibly we could agree to the age-old
convention that method names are verb phrases and column names are noun
phrases?

> Class::DBI has to be really careful when adding new methods in case
> they clash with likely column names[1]. Maypole is going to have to
> be equally careful in this regard.

I utterly agree with the spirit but ...

> [1] Obviously almost anything could be a column name. If someone has
> a column called 'has_many', or 'discard_changes', Class::DBI isn't
> happy unless they rename their column. Having a column called
> 'accessor_name' is really going to screw things up. But I've had to
> get rid of methods like 'min' and 'max' which are fairly column
> names, and replace them with 'minimum_value_of' and
> 'maximum_value_of'.

Cheers, Dave

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.298 / Virus Database: 265.6.6 - Release Date: 28/12/04

_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT