lgn8412 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, this a matter that has been giving me problems lately on my internship, I need to create the schemas from a database model that has poorly named tables, so it has problems with the moniker mapping, my interest in this is that I don't want to use singularization of names at all, and just leave things as they are, I'm currently using this command to create the model:

perl script/nombreapp_create.pl model DB DBIC::Schema App::Schema create=static 'dbi:Oracle:sid=DATA;host=xxx.xxx.xxx.xxx;port=1521' 'user' 'password' '{AutoCommit => 0  }' 'naming => { relationships => 'v4', monikers => 'v4' }'

and it returns this as output:

Unable to load schema - chosen moniker/class naming style results in moniker clashes. Either change the naming style, or supply an explicit moniker_map: tables 'first_mickeymouse', 'first_mickeymouses' reduced to the same source moniker 'FirstMickeymouse'

I don't really want to get into the trouble of creating a moniker map for this.. unless there isn't anything else I can do, I'd really appreciate any help, thanks in advance =)

Thanks to "Your Mother" for the help. I found the solution, my boss helped me with it, I'm going to post it here just for future reference to others =)

perl script/nameapp_create.pl model DB DBIC::Schema DATABASE::Schema create=static naming=v4 'dbi:Oracle:sid=DATA;host=xxx.xxx.xxx.xxx;port=1521' 'username' 'password' "{AutoCommit => 0}"

I think it's the same if you want to make moniker maps, the thing was placing the naming flag in the right place

Replies are listed 'Best First'.
Re: DBI::Class::Loader using naming properly
by Your Mother (Archbishop) on Nov 29, 2010 at 15:09 UTC

    It's DBIx::Class, often abbreviated as DBIC, just to be clear.

    What you want is what the error message suggests: moniker_map. You'll find its documentation here: DBIx::Class::Schema::Loader::Base. So, here is an untested snippet to get you started with your result source classes named as is (no transform on the table names).

    perl script/nombreapp_create.pl model \ DB DBIC::Schema App::Schema \ create=static 'dbi:Oracle:sid=DATA;host=xxx.xxx.xxx.xxx;port=1521' +\ 'user' 'password' '{AutoCommit => 0 }' \ 'naming => { moniker_map => sub { +shift } }'

    You will probably need to write your own moniker_map sub to get exactly what you want. If mouses -> mice is the kind of problem you're facing you might look at Lingua::EN::Inflect (which is used by default in the DBIC stuff).