blib/lib/SQL/Translator/Producer/SQLServer.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 93.3% 28 / 30 CC 1 SCAR 0.0
CC
1
Cov
96%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/SQL/Translator/Generator/DDL/PostgreSQL.pm ↑ Summary blib/lib/SQL/Translator/Parser/XML.pm »
1 package SQL::Translator::Producer::SQLServer;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our ($DEBUG, $WARN);
6 2 our $VERSION = '1.66';
7 2 ▶$DEBUG = 1 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $SQL::Translator::Producer::SQLServer::DEBUG 2 0 2
8  
9 2 ▶use SQL::Translator::Schema::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use SQL::Translator::Utils qw(debug header_comment);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use SQL::Translator::Generator::DDL::SQLServer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶sub produce {
Subroutine produce: called CC=1 SCAR=0.0
Pod undocumented
14 3 my $translator = shift;
15 3 SQL::Translator::Generator::DDL::SQLServer->new(
16 add_comments => !$translator->no_comments,
17 add_drop_table => $translator->add_drop_table,
18 )->schema($translator->schema);
19 }
20  
21 2 1;
22  
23 =head1 NAME
24  
25 SQL::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  
36 This is currently a thin wrapper around the nextgen
37 L<SQL::Translator::Generator::DDL::SQLServer> DDL maker.
38  
39 =head1 Extra Attributes
40  
41 =over 4
42  
43 =item field.list
44  
45 List 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  
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";
61 $output .= "--\n-- View: $name\n--\n\n" unless $no_comments;
62 my $text = $_->sql();
63 $text =~ s/\r//g;
64 $output .= "$text\nGO\n";
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";
74 $output .= "--\n-- Procedure: $name\n--\n\n" unless $no_comments;
75 my $text = $_->sql();
76 $text =~ s/\r//g;
77 $output .= "$text\nGO\n";
78 }
79  
80 =head1 SEE ALSO
81  
82 L<SQL::Translator>
83  
84 =head1 AUTHORS
85  
86 See the included AUTHORS file:
87 L<http://search.cpan.org/dist/SQL-Translator/AUTHORS>
88  
89 =head1 COPYRIGHT
90  
91 Copyright (c) 2012 the SQL::Translator L</AUTHORS> as listed above.
92  
93 =head1 LICENSE
94  
95 This code is free software and may be distributed under the same terms as Perl
96 itself.
97  
98 =cut
« blib/lib/SQL/Translator/Generator/DDL/PostgreSQL.pm ↑ Summary blib/lib/SQL/Translator/Parser/XML.pm »