SQL::Tr...::Names(3)

🌸 NAME 🌸

okay bestie, welcome to the SQL::Tr...::Names(3) manual page β€” it's giving name-glow-up energy ✨ This one is SQL::Translator::Filter::Names β€” tweak the names of schema objects. That's the whole vibe: rename stuff in your schema so it looks exactly how you want. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

Like, here's the whole little script moment, copied exactly so you can see the fit πŸ‘‘

  #! /usr/bin/perl -w
  use SQL::Translator;

  # Lowercase all table names and upper case the first letter of all field
  # names. (MySql style!)
  #
  my $sqlt = SQL::Translator->new(
      filename => \@ARGV,
      from     => 'MySQL',
      to       => 'MySQL',
      filters => [
        Names => {
            'tables' => 'lc',
            'fields' => 'ucfirst',
        },
      ],
  ) || die "SQLFairy error : ".SQL::Translator->error;
  print($sqlt->translate) || die "SQLFairy error : ".$sqlt->error;

πŸ¦‹ DESCRIPTION πŸ¦‹

So basically: you tweak the names of schema objects by giving it functions that filter the names from whatever you've got into the desired forms. Name filter era, no cap 🫢


πŸ‘€ SEE ALSO πŸ‘€

perl(1), SQL::Translator

πŸŽ€ Name Groups πŸŽ€

Define a bunch of useful groups to run the name filters over. e.g. all, fkeys, pkeys etc. Group-chat for filters vibes 🌈

✨ More Functions ✨

e.g. camelcase, titlecase, single word etc. Also a way to pass in a regexp.

May also want a way to pass in arguments for the func e.g. prefix. func args era πŸ”₯

πŸ’… Multiple Filters on the same name (filter order)? πŸ’…

Do we actually need this, you could just run lots of filters. Would make adding func args to the interface easier.

    filters => [
        [ 'Names', { all => 'lc' } ],
        [ 'Names', {
            tables => 'lc',
            fields => 'ucfirst',
        } ],
    ],

Mind you if you could give the filter a list this wouldn't be a problem!

    filters => [
        [ 'Names',
            all    => 'lc'
            fields => 'ucfirst',
        ],
    ],

Which is nice. Might have to change the calling conventions for filters. Would also provide an order to run the filters in rather than having to hard code it into the filter it's self. filter-order brainrot, but make it organized πŸ’€


cute little sign-off bestie: this page is from perl v5.42.0, dated 2024-12-12, and it's the SQL::Tr...::Names(3) manual β€” slay, bye πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from