1 package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault;
5 use base 'DBIx::Class::Schema::Loader::DBI';
8 our $VERSION = '0.07036_03';
12 DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault -- Loader::DBI
13 Component to parse quoted default constants and functions
17 If C<COLUMN_DEF> from L<DBI/column_info> returns character constants quoted,
18 then we need to remove the quotes. This also allows distinguishing between
19 default functions without information schema introspection.
23 sub _columns_info_for {
27 my $result = $self->next::method(@_);
29 while (my ($col, $info) = each %$result) {
30 if (my $def = $info->{default_value}) {
34 # remove Pg typecasts (e.g. 'foo'::character varying) too
35 if ($def =~ /^["'](.*?)['"](?:::[\w\s]+)?\z/) {
36 $info->{default_value} = $1;
38 # Some DBs (eg. Pg) put parenthesis around negative number defaults
39 elsif ($def =~ /^\((-?\d.*?)\)(?:::[\w\s]+)?\z/) {
40 $info->{default_value} = $1;
42 elsif ($def =~ /^(-?\d.*?)(?:::[\w\s]+)?\z/) {
43 $info->{default_value} = $1;
45 elsif ($def =~ /^NULL:?/i) {
47 $info->{default_value} = \$null;
50 $info->{default_value} = \$def;
62 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
63 L<DBIx::Class::Schema::Loader::DBI>
67 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
71 This library is free software; you can redistribute it and/or modify it under
72 the same terms as Perl itself.