Remove empty sections
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Filter / DefaultExtra.pm
CommitLineData
6cedfc23 1package SQL::Translator::Filter::DefaultExtra;
2
6cedfc23 3=head1 NAME
4
5SQL::Translator::Filter::DefaultExtra - Set default extra data values for schema
6objects.
7
8=head1 SYNOPSIS
9
10 use SQL::Translator;
11
12 my $sqlt = SQL::Translator->new(
13 from => 'MySQL',
14 to => 'MySQL',
15 filters => [
16 DefaultExtra => {
17 # XXX - These should really be ordered
ea93df61 18
6cedfc23 19 # Default widget for fields to basic text edit.
20 'field.widget' => 'text',
21 # idea:
22 'field(data_type=BIT).widget' => 'yesno',
23
24 # Default label (human formated name) for fields and tables
25 'field.label' => '=ucfirst($name)',
26 'table.label' => '=ucfirst($name)',
ea93df61 27 },
6cedfc23 28 ],
29 ) || die "SQLFairy error : ".SQL::Translator->error;
30 my $sql = $sqlt->translate || die "SQLFairy error : ".$sqlt->error;
31
32=cut
33
34use strict;
f27f9229 35use warnings;
0c04c5a2 36our $VERSION = '1.59';
6cedfc23 37
38sub filter {
39 my $schema = shift;
40 my %args = { +shift };
41
42 # Tables
11ad2df9 43 foreach ( $schema->get_tables ) {
6cedfc23 44 my %extra = $_->extra;
45
46 $extra{label} ||= ucfirst($_->name);
47 $_->extra( %extra );
48 }
49
50 # Fields
11ad2df9 51 foreach ( map { $_->get_fields } $schema->get_tables ) {
6cedfc23 52 my %extra = $_->extra;
53
54 $extra{label} ||= ucfirst($_->name);
55 $_->extra( %extra );
56 }
57}
58
591;
60
61__END__
62
63=head1 DESCRIPTION
64
11ad2df9 65Maybe I'm trying to do too much in one go. Args set a match and then an update,
66if you want to set lots of things, use lots of filters!
6cedfc23 67
68=head1 SEE ALSO
69
0e9badbf 70C<perl(1)>, L<SQL::Translator>
6cedfc23 71
6cedfc23 72=cut