Force everything to 1.99, hopefully will work
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer.pm
CommitLineData
16dc9970 1package SQL::Translator::Producer;
2
49e1eb70 3# -------------------------------------------------------------------
d4f84dd1 4# $Id: Producer.pm 1440 2009-01-17 16:31:57Z jawnsy $
49e1eb70 5# -------------------------------------------------------------------
977651a5 6# Copyright (C) 2002-4 SQLFairy Authors
077ebf34 7#
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.
16dc9970 11#
077ebf34 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.
16dc9970 16#
077ebf34 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
20# 02111-1307 USA
21# -------------------------------------------------------------------
22
23use strict;
da06ac74 24use vars qw($VERSION);
25$VERSION = '1.99';
16dc9970 26
077ebf34 27sub produce { "" }
16dc9970 28
bc8e2aa1 29# Do not rely on this if you are not bundled with SQL::Translator.
30# -- rjbs, 2008-09-30
31## $exceptions contains an arrayref of paired values
32## Each pair contains a pattern match or string, and a value to be used as
33## the default if matched.
34## They are special per Producer, and provide support for the old 'now()'
35## default value exceptions
36sub _apply_default_value {
0f4c1a5b 37 my (undef, $field_ref, $default, $exceptions) = @_;
bc8e2aa1 38
39 if ($exceptions and ! ref $default) {
40 for (my $i = 0; $i < @$exceptions; $i += 2) {
41 my ($pat, $val) = @$exceptions[ $i, $i + 1 ];
42 if (ref $pat and $default =~ $pat) {
43 $default = $val;
44 last;
45 } elsif (lc $default eq lc $pat) {
46 $default = $val;
47 last
48 }
49 }
50 }
51
52 if (ref $default) {
53 $$field_ref .= " DEFAULT $$default";
54 } else {
0f4c1a5b 55 $$field_ref .= " DEFAULT '$default'";
bc8e2aa1 56 }
57
58}
59
16dc9970 601;
61
49e1eb70 62# -------------------------------------------------------------------
16dc9970 63# A burnt child loves the fire.
64# Oscar Wilde
49e1eb70 65# -------------------------------------------------------------------
66
67=pod
16dc9970 68
69=head1 NAME
70
56435d6f 71SQL::Translator::Producer - describes how to write a producer
16dc9970 72
16dc9970 73=head1 DESCRIPTION
74
077ebf34 75Producer modules designed to be used with SQL::Translator need to
76implement a single function, called B<produce>. B<produce> will be
56435d6f 77called with the SQL::Translator object from which it is expected to
78retrieve the SQL::Translator::Schema object which has been populated
79by the parser. It is expected to return a string.
16dc9970 80
0e1ec14f 81=head1 METHODS
82
83=over 4
84
85=item produce
86
87=item create_table($table)
88
89=item create_field($field)
90
91=item create_view($view)
92
93=item create_index($index)
94
95=item create_constraint($constraint)
96
97=item create_trigger($trigger)
98
99=item alter_field($from_field, $to_field)
100
101=item add_field($table, $new_field)
102
103=item drop_field($table, $old_field)
104
56435d6f 105=head1 AUTHORS
16dc9970 106
56435d6f 107Darren Chamberlain E<lt>darren@cpan.orgE<gt>,
108Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
16dc9970 109
110=head1 SEE ALSO
111
56435d6f 112perl(1), SQL::Translator, SQL::Translator::Schema.
16dc9970 113
114=cut