From: Dagfinn Ilmari Mannsåker Date: Sat, 13 Jun 2015 13:31:33 +0000 (+0100) Subject: Fix Pg date/time types with zero fractional second digits X-Git-Tag: 0.07044~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a6fd0a48650a165b84866c1d14b65d35f25ef416;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix Pg date/time types with zero fractional second digits --- diff --git a/Changes b/Changes index 7f1153b..d71d1e0 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - Fix Pg date/time types with zero fractional second digits + 0.07043 2015-05-13 - Fix many_to_many bridges with overlapping foreign keys - Add option to allow extra columns in many_to_many link tables diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 403161a..a70106a 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -227,7 +227,7 @@ WHERE table_name = ? and column_name = ? EOF if ($data_type =~ /^time\b/i) { - if ((not $precision) || $precision !~ /^\d/) { + if ((not defined $precision) || $precision !~ /^\d/) { delete $info->{size}; } else { @@ -245,7 +245,7 @@ EOF } } } - elsif ((not $precision) || $precision !~ /^\d/ || $precision == 6) { + elsif ((not defined $precision) || $precision !~ /^\d/ || $precision == 6) { delete $info->{size}; } else { diff --git a/t/10_03pg_common.t b/t/10_03pg_common.t index 1033264..1d392dd 100644 --- a/t/10_03pg_common.t +++ b/t/10_03pg_common.t @@ -121,22 +121,28 @@ dbixcsl_common_tests->new( # Datetime Types date => { data_type => 'date' }, interval => { data_type => 'interval' }, + 'interval(0)' => { data_type => 'interval', size => 0 }, 'interval(2)' => { data_type => 'interval', size => 2 }, time => { data_type => 'time' }, + 'time(0)' => { data_type => 'time', size => 0 }, 'time(2)' => { data_type => 'time', size => 2 }, 'time without time zone' => { data_type => 'time' }, - 'time(2) without time zone' => { data_type => 'time', size => 2 }, + 'time(0) without time zone' => { data_type => 'time', size => 0 }, 'time with time zone' => { data_type => 'time with time zone' }, + 'time(0) with time zone' => { data_type => 'time with time zone', size => 0 }, 'time(2) with time zone' => { data_type => 'time with time zone', size => 2 }, timestamp => { data_type => 'timestamp' }, 'timestamp default now()' => { data_type => 'timestamp', default_value => \'current_timestamp', original => { default_value => \'now()' } }, + 'timestamp(0)' => { data_type => 'timestamp', size => 0 }, 'timestamp(2)' => { data_type => 'timestamp', size => 2 }, 'timestamp without time zone' => { data_type => 'timestamp' }, + 'timestamp(0) without time zone' => { data_type => 'timestamp', size => 0 }, 'timestamp(2) without time zone' => { data_type => 'timestamp', size => 2 }, 'timestamp with time zone' => { data_type => 'timestamp with time zone' }, + 'timestamp(0) with time zone' => { data_type => 'timestamp with time zone', size => 0 }, 'timestamp(2) with time zone' => { data_type => 'timestamp with time zone', size => 2 }, # Blob Types