1 package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault;
7 our $VERSION = '0.07014';
11 DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault -- Loader::DBI
12 Component to parse quoted default constants and functions
16 If C<COLUMN_DEF> from L<DBI/column_info> returns character constants quoted,
17 then we need to remove the quotes. This also allows distinguishing between
18 default functions without information schema introspection.
22 sub _columns_info_for {
26 my $result = $self->next::method(@_);
28 while (my ($col, $info) = each %$result) {
29 if (my $def = $info->{default_value}) {
33 # remove Pg typecasts (e.g. 'foo'::character varying) too
34 if ($def =~ /^["'](.*?)['"](?:::[\w\s]+)?\z/) {
35 $info->{default_value} = $1;
37 # Some DBs (eg. Pg) put parenthesis around negative number defaults
38 elsif ($def =~ /^\((-?\d.*?)\)(?:::[\w\s]+)?\z/) {
39 $info->{default_value} = $1;
41 elsif ($def =~ /^(-?\d.*?)(?:::[\w\s]+)?\z/) {
42 $info->{default_value} = $1;
44 elsif ($def =~ /^NULL:?/i) {
46 $info->{default_value} = \$null;
49 $info->{default_value} = \$def;
61 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
62 L<DBIx::Class::Schema::Loader::DBI>
66 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
70 This library is free software; you can redistribute it and/or modify it under
71 the same terms as Perl itself.