[Dbix-class] DBIx::Class:Schema::Loader has_many relationship names

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Fri Feb 24 15:45:41 CET 2006


Brandon Black wrote:
> On 2/24/06, Adam Sjøgren <asjo at koldfront.dk> wrote:
>>On Fri, 24 Feb 2006 12:42:02 +0000, Matt wrote:
>>
>>>That's because the default inflect code doesn't handle plurals - if you
>>>want non-default behaviour, pass it an inflect_map option.
>>(Ok - I was trying to ask what the default behaviour is supposed to be
>>:-))
>>
>>>I can see your reasoning but the vast majority of users (I think) have
>>>singular table names rather than plural, so the default config caters to
>>>that.
>>Ok, that makes sense (the default working with what most people do).
>>
>>Do most people really name their tables in the singular? I find that
>>quite confusing.
> 
> I also make my table names plural, although in light of all the
> discussions that have popped up from this, I'll probably change that
> habit next time around.

I use plural table names because I like my SQL to read nicely :)

> When making the has_many name, Loader uses
> Lingua::EN::Inflect::pluralize on the table name. 
> Lingua::EN::Inflect::pluralize docs say the result is"undefined" when
> you pass in an already plural name (but the result tends to really be
> that it strips pluralization).
> 
> It needs a better solution, I just haven't though of one yet.

I use Lingua::EN::Inflect::Number with its to_S and to_PL functions. It 
works and can be updated so they still work if Lingua::EN::Inflect's 
behaviour ever changes.

That way the automatic inflection works whatever convention has been 
chosen for table names (and column names, come to that).

Cheers, Dave



More information about the Dbix-class mailing list