Bumping version to 1.61
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / SQLServer.pm
CommitLineData
7a0ceaa1 1package SQL::Translator::Producer::SQLServer;
2
7a0ceaa1 3use strict;
f27f9229 4use warnings;
0c04c5a2 5our ( $DEBUG, $WARN );
752a0ffc 6our $VERSION = '1.61';
7a0ceaa1 7$DEBUG = 1 unless defined $DEBUG;
8
7a0ceaa1 9use SQL::Translator::Schema::Constants;
10use SQL::Translator::Utils qw(debug header_comment);
c661b77d 11use SQL::Translator::Generator::DDL::SQLServer;
0a6e5a56 12
7a0ceaa1 13sub produce {
9a6c1bf9 14 my $translator = shift;
15 SQL::Translator::Generator::DDL::SQLServer->new(
16 add_comments => !$translator->no_comments,
f851dfea 17 add_drop_table => $translator->add_drop_table,
9a6c1bf9 18 )->schema($translator->schema)
871f55d4 19}
20
056238d8 211;
22
056238d8 23=head1 NAME
24
25SQL::Translator::Producer::SQLServer - MS SQLServer producer for SQL::Translator
26
27=head1 SYNOPSIS
28
29 use SQL::Translator;
30
31 my $t = SQL::Translator->new( parser => '...', producer => 'SQLServer' );
32 $t->translate;
33
34=head1 DESCRIPTION
35
22c0c10f 36This is currently a thin wrapper around the nextgen
37L<SQL::Translator::Generator::DDL::SQLServer> DDL maker.
056238d8 38
39=head1 Extra Attributes
40
41=over 4
42
43=item field.list
44
45List of values for an enum field.
46
47=back
48
49=head1 TODO
50
51 * !! Write some tests !!
52 * Reserved words list needs updating to SQLServer.
53 * Triggers, Procedures and Views DO NOT WORK
54
55
7a0ceaa1 56 # Text of view is already a 'create view' statement so no need to
57 # be fancy
58 foreach ( $schema->get_views ) {
59 my $name = $_->name();
60 $output .= "\n\n";
5c5997ef 61 $output .= "--\n-- View: $name\n--\n\n" unless $no_comments;
3e0bcbfd 62 my $text = $_->sql();
e2fb9ad3 63 $text =~ s/\r//g;
5bb0a4ee 64 $output .= "$text\nGO\n";
7a0ceaa1 65 }
66
67 # Text of procedure already has the 'create procedure' stuff
68 # so there is no need to do anything fancy. However, we should
69 # think about doing fancy stuff with granting permissions and
70 # so on.
71 foreach ( $schema->get_procedures ) {
72 my $name = $_->name();
73 $output .= "\n\n";
5c5997ef 74 $output .= "--\n-- Procedure: $name\n--\n\n" unless $no_comments;
3e0bcbfd 75 my $text = $_->sql();
028386aa 76 $text =~ s/\r//g;
5bb0a4ee 77 $output .= "$text\nGO\n";
7a0ceaa1 78 }
7a0ceaa1 79
80=head1 SEE ALSO
81
22c0c10f 82L<SQL::Translator>
7a0ceaa1 83
84=head1 AUTHORS
85
22c0c10f 86See the included AUTHORS file:
87L<http://search.cpan.org/dist/SQL-Translator/AUTHORS>
88
89=head1 COPYRIGHT
90
91Copyright (c) 2012 the SQL::Translator L</AUTHORS> as listed above.
92
93=head1 LICENSE
94
95This code is free software and may be distributed under the same terms as Perl
96itself.
7a0ceaa1 97
98=cut