line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
133
|
use strict; |
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
463
|
|
4
|
16
|
|
|
16
|
|
97
|
use warnings; |
|
16
|
|
|
|
|
81
|
|
|
16
|
|
|
|
|
511
|
|
5
|
16
|
|
|
16
|
|
90
|
use base 'DBIx::Class::Schema::Loader::DBI'; |
|
16
|
|
|
|
|
40
|
|
|
16
|
|
|
|
|
2395
|
|
6
|
16
|
|
|
16
|
|
128
|
use mro 'c3'; |
|
16
|
|
|
|
|
40
|
|
|
16
|
|
|
|
|
98
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.07051'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault -- Loader::DBI |
13
|
|
|
|
|
|
|
Component to parse quoted default constants and functions |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
If C from L returns character constants quoted, |
18
|
|
|
|
|
|
|
then we need to remove the quotes. This also allows distinguishing between |
19
|
|
|
|
|
|
|
default functions without information schema introspection. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _columns_info_for { |
24
|
766
|
|
|
766
|
|
10905
|
my $self = shift; |
25
|
766
|
|
|
|
|
2329
|
my ($table) = @_; |
26
|
|
|
|
|
|
|
|
27
|
766
|
|
|
|
|
2848
|
my ($result,$raw) = $self->next::method(@_); |
28
|
|
|
|
|
|
|
|
29
|
766
|
|
|
|
|
5328
|
while (my ($col, $info) = each %$result) { |
30
|
2156
|
100
|
|
|
|
9862
|
if (my $def = $info->{default_value}) { |
31
|
202
|
|
|
|
|
953
|
$def =~ s/^\s+//; |
32
|
202
|
|
|
|
|
772
|
$def =~ s/\s+\z//; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# remove Pg typecasts (e.g. 'foo'::character varying) too |
35
|
202
|
100
|
|
|
|
2374
|
if ($def =~ /^["'](.*?)['"](?:::[\w\s]+)?\z/) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
36
|
87
|
|
|
|
|
787
|
$info->{default_value} = $1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
# Some DBs (eg. Pg) put parenthesis around negative number defaults |
39
|
|
|
|
|
|
|
elsif ($def =~ /^\((-?\d.*?)\)(?:::[\w\s]+)?\z/) { |
40
|
0
|
|
|
|
|
0
|
$info->{default_value} = $1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($def =~ /^(-?\d.*?)(?:::[\w\s]+)?\z/) { |
43
|
28
|
|
|
|
|
137
|
$info->{default_value} = $1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ($def =~ /^NULL:?/i) { |
46
|
0
|
|
|
|
|
0
|
my $null = 'null'; |
47
|
0
|
|
|
|
|
0
|
$info->{default_value} = \$null; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
87
|
|
|
|
|
715
|
$info->{default_value} = \$def; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
766
|
50
|
|
|
|
10768
|
return wantarray ? ($result, $raw) : $result; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SEE ALSO |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L, L, |
63
|
|
|
|
|
|
|
L |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHORS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
See L. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
72
|
|
|
|
|
|
|
the same terms as Perl itself. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |