line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Schema::Changelog::Action::Function; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBIx::Schema::Changelog::Action::Function - Action for functions |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.8.0 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.8.0'; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
37
|
use utf8; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
54
|
|
16
|
5
|
|
|
5
|
|
218
|
use strict; |
|
5
|
|
|
|
|
65
|
|
|
5
|
|
|
|
|
294
|
|
17
|
5
|
|
|
5
|
|
36
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
263
|
|
18
|
5
|
|
|
5
|
|
39
|
use Moose; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
58
|
|
19
|
5
|
|
|
5
|
|
62589
|
use Data::Dumper; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
3678
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
with 'DBIx::Schema::Changelog::Action'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item add |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Execute sql statements can lead very likely to incompatibilities. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add { |
34
|
0
|
|
|
0
|
1
|
|
my ( $self, $params, $return_sql ) = @_; |
35
|
0
|
|
|
|
|
|
my $functions = $self->driver()->functions; |
36
|
0
|
0
|
|
|
|
|
die "Used driver does not support functions!" unless $functions; |
37
|
0
|
0
|
|
|
|
|
die "No function name defined!" unless $params->{name}; |
38
|
0
|
|
|
|
|
|
my $insert_params = |
39
|
|
|
|
|
|
|
( defined $params->{params} && ref $params->{params} eq 'ARRAY' ) |
40
|
0
|
0
|
0
|
|
|
|
? join( ',', @{ $params->{params} } ) |
41
|
|
|
|
|
|
|
: ''; |
42
|
0
|
0
|
|
|
|
|
my $cost = ( defined $params->{cost} ) ? $params->{cost} . '' : '100'; |
43
|
0
|
0
|
|
|
|
|
my $lang = ( defined $params->{lang} ) ? $params->{lang} : 'sql'; |
44
|
0
|
|
|
|
|
|
my $sql = _replace_spare( |
45
|
|
|
|
|
|
|
$functions->{add}, |
46
|
|
|
|
|
|
|
[ |
47
|
|
|
|
|
|
|
$params->{name}, $insert_params, $params->{return}, |
48
|
|
|
|
|
|
|
$params->{as}, $lang, $cost |
49
|
|
|
|
|
|
|
] |
50
|
|
|
|
|
|
|
); |
51
|
0
|
0
|
|
|
|
|
return ($return_sql) ? $sql : $self->_do($sql); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item alter |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Not needed! |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub alter { |
61
|
0
|
|
|
0
|
1
|
|
my ( $self, $params, $return_sql ) = @_; |
62
|
0
|
|
|
|
|
|
my $drop = $self->drop( $params, $return_sql ); |
63
|
0
|
|
|
|
|
|
my $add = $self->add( $params, $return_sql ); |
64
|
0
|
|
|
|
|
|
return { drop => $drop, add => $add }; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item drop |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Not needed! |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub drop { |
74
|
0
|
|
|
0
|
1
|
|
my ( $self, $params, $return_sql ) = @_; |
75
|
0
|
|
|
|
|
|
my $functions = $self->driver()->functions; |
76
|
0
|
0
|
|
|
|
|
die "Used driver does not support functions!" unless $functions; |
77
|
0
|
|
|
|
|
|
my $insert_params = |
78
|
|
|
|
|
|
|
( defined $params->{params} && ref $params->{params} eq 'ARRAY' ) |
79
|
0
|
0
|
0
|
|
|
|
? join( ',', @{ $params->{params} } ) |
80
|
|
|
|
|
|
|
: ''; |
81
|
0
|
|
|
|
|
|
my $sql = |
82
|
|
|
|
|
|
|
_replace_spare( $functions->{drop}, [ $params->{name}, $insert_params ], |
83
|
|
|
|
|
|
|
1 ); |
84
|
0
|
0
|
|
|
|
|
return ($return_sql) ? $sql : $self->_do($sql); |
85
|
|
|
|
|
|
|
} |
86
|
5
|
|
|
5
|
|
45
|
no Moose; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
50
|
|
87
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Mario Zieschang, C<< <mario.zieschang at combase.de> >> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright 2015 Mario Zieschang. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
104
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
105
|
|
|
|
|
|
|
copy of the full license at: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
110
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
111
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
112
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
115
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
116
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
119
|
|
|
|
|
|
|
mark, trade name, or logo of the Copyright Holder. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
122
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
123
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
124
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
125
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
126
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
127
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
128
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
131
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
132
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR |
133
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
134
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
135
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
136
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
137
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |