X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FComponent%2FQuotedDefault.pm;h=772dbb24b252fab86f761a99986834a220c5b271;hb=afa71a988919e114101e41f0241b08ffc2f436f5;hp=b71f2ce3fb03af4a242aabd296e4d5fd1f88ef22;hpb=2a8e93e98aace9a187a57a66a8d71fabc6a48a8c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm b/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm index b71f2ce..772dbb2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm @@ -2,9 +2,10 @@ package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault; use strict; use warnings; -use Class::C3; +use base 'DBIx::Class::Schema::Loader::DBI'; +use mro 'c3'; -our $VERSION = '0.06000'; +our $VERSION = '0.07048_01'; =head1 NAME @@ -23,7 +24,7 @@ sub _columns_info_for { my $self = shift; my ($table) = @_; - my $result = $self->next::method(@_); + my ($result,$raw) = $self->next::method(@_); while (my ($col, $info) = each %$result) { if (my $def = $info->{default_value}) { @@ -34,13 +35,24 @@ sub _columns_info_for { if ($def =~ /^["'](.*?)['"](?:::[\w\s]+)?\z/) { $info->{default_value} = $1; } +# Some DBs (eg. Pg) put parenthesis around negative number defaults + elsif ($def =~ /^\((-?\d.*?)\)(?:::[\w\s]+)?\z/) { + $info->{default_value} = $1; + } + elsif ($def =~ /^(-?\d.*?)(?:::[\w\s]+)?\z/) { + $info->{default_value} = $1; + } + elsif ($def =~ /^NULL:?/i) { + my $null = 'null'; + $info->{default_value} = \$null; + } else { - $info->{default_value} = $def =~ /^\d/ ? $def : \$def; + $info->{default_value} = \$def; } } } - return $result; + return wantarray ? ($result, $raw) : $result; } 1; @@ -50,9 +62,9 @@ sub _columns_info_for { L, L, L -=head1 AUTHOR +=head1 AUTHORS -See L and L. +See L. =head1 LICENSE