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