line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Translator::Producer::SQLServer; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3918
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
5
|
|
|
|
|
|
|
our ( $DEBUG, $WARN ); |
6
|
|
|
|
|
|
|
our $VERSION = '1.63'; |
7
|
|
|
|
|
|
|
$DEBUG = 1 unless defined $DEBUG; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
8
|
use SQL::Translator::Schema::Constants; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
116
|
|
10
|
1
|
|
|
1
|
|
9
|
use SQL::Translator::Utils qw(debug header_comment); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
57
|
|
11
|
1
|
|
|
1
|
|
566
|
use SQL::Translator::Generator::DDL::SQLServer; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
119
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub produce { |
14
|
2
|
|
|
2
|
0
|
6
|
my $translator = shift; |
15
|
2
|
|
|
|
|
57
|
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
|
|
|
|
|
|
|
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 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 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHORS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
See the included AUTHORS file: |
87
|
|
|
|
|
|
|
L |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright (c) 2012 the SQL::Translator L 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 |