1 package SQL::Translator::Filter::DefaultExtra;
3 # -------------------------------------------------------------------
4 # Copyright (C) 2002-2009 SQLFairy Authors
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 # -------------------------------------------------------------------
23 SQL::Translator::Filter::DefaultExtra - Set default extra data values for schema
30 my $sqlt = SQL::Translator->new(
35 # XXX - These should really be ordered
37 # Default widget for fields to basic text edit.
38 'field.widget' => 'text',
40 'field(data_type=BIT).widget' => 'yesno',
42 # Default label (human formated name) for fields and tables
43 'field.label' => '=ucfirst($name)',
44 'table.label' => '=ucfirst($name)',
47 ) || die "SQLFairy error : ".SQL::Translator->error;
48 my $sql = $sqlt->translate || die "SQLFairy error : ".$sqlt->error;
53 use vars qw/$VERSION/;
58 my %args = { +shift };
61 foreach ( $schema->get_tables ) {
62 my %extra = $_->extra;
64 $extra{label} ||= ucfirst($_->name);
69 foreach ( map { $_->get_fields } $schema->get_tables ) {
70 my %extra = $_->extra;
72 $extra{label} ||= ucfirst($_->name);
83 Maybe I'm trying to do too much in one go. Args set a match and then an update,
84 if you want to set lots of things, use lots of filters!
88 L<perl(1)>, L<SQL::Translator>