Release 0.07047
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / Component / QuotedDefault.pm
index 3fec4f7..70694f2 100644 (file)
@@ -2,9 +2,10 @@ package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault;
 
 use strict;
 use warnings;
+use base 'DBIx::Class::Schema::Loader::DBI';
 use mro 'c3';
 
-our $VERSION = '0.07001';
+our $VERSION = '0.07047';
 
 =head1 NAME
 
@@ -34,9 +35,19 @@ 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 {
-                # Some DBs (eg. Pg) put brackets around negative number defaults
-                $info->{default_value} = $def =~ /^\(?(-?\d.*?)\)?$/ ? $1 : \$def;
+                $info->{default_value} = \$def;
             }
         }
     }
@@ -51,9 +62,9 @@ sub _columns_info_for {
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+See L<DBIx::Class::Schema::Loader/AUTHORS>.
 
 =head1 LICENSE