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

I'm kicking the tires of DBIC. One thing that annoys me is that it uses camel case for table names. I tried to fix this by setting the 'naming' property to 'preserve' like so:

make_schema_at ( 'Schema', { debug => 1, dump_directory => '.', naming => { ALL => 'preserve' }, really_erase_my_files => 1, }, [$self->dsn, $self->db_user, $self->db_pass], );

No dice. How do I do it? Documentation here.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

  • Comment on DBIC: How to dump schema with underscores for table names instead of camel case?
  • Download Code

Replies are listed 'Best First'.
Re: DBIC: How to dump schema with underscores for table names instead of camel case?
by nysus (Parson) on Feb 10, 2017 at 07:17 UTC

    Bam! Got it. Finally.

    make_schema_at ( 'Schema', { debug => 1, dump_directory => '.', moniker_map => \&_get_moniker, }, [$self->dsn, $self->db_user, $self->db_pass], ); sub _get_moniker { return shift; #returns original table name with no modifications }

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Re: DBIx: How to dump schema with underscores for table names instead of camel case?
by Marshall (Canon) on Feb 09, 2017 at 18:37 UTC
    Update:
    I misread the question. Sorry. Looks like this new V8 stuff is to make Camelcase work when the objective is to not make Camelcase work. In that case maybe some lower "name" parameter other than v8 will do the trick?
    ------

    This may not be of much help as I have almost no experience with this. The docs are pretty complicated. But look at naming. Something like naming => { ALL => 'v8', force_ascii => 1 } looks appropriate,

    And also, see v8 discussion:

    v8

    (EXPERIMENTAL) The default mode is "v7", to get "v8" mode, you have to specify it in "naming" explicitly until 0.08 comes out. "monikers" and "column_accessors" are created using String::ToIdentifier::EN::Unicode or String::ToIdentifier::EN if "force_ascii" is set; this is only significant for names with non-\w characters such as .. CamelCase identifiers with words in all caps, e.g. VLANValidID are supported correctly in this mode. For relationships, belongs_to accessors are made from column names by stripping postfixes other than _id as well, for example just Id, _?ref, _?cd, _?code and _?num, case insensitively.
Re: DBIC: How to dump schema with underscores for table names instead of camel case?
by Your Mother (Archbishop) on Feb 10, 2017 at 03:57 UTC

    Just do the dump once and edit the files by hand. Unless you have a a ton of tables it will take 5 minutes tops.

      Ha! I was just coming here to suggest that might be one way to do it. It feels so dirty, though. And maybe there is good reason to make it camel case. Maybe something might break if I don't. Not sure why I agonize over this stuff. Curiosity more than anything.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks