From: Rafael Kitover Date: Fri, 22 Jan 2010 06:19:19 +0000 (+0000) Subject: better handling of default precision for TIME type in Pg X-Git-Tag: 0.05000~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5f85388e89577691c0c23289f90c47dbfb1782bb;p=dbsrgits%2FDBIx-Class-Schema-Loader.git better handling of default precision for TIME type in Pg --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 1a1efdc..952596a 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -147,8 +147,26 @@ FROM information_schema.columns WHERE table_name = ? and column_name = ? EOF - if ((not $precision) || $precision !~ /^\d/ - || ($data_type !~ /^time\b/i && $precision == 6)) { # only interval/timestamp default to precision == 6 + if ($data_type =~ /^time\b/i) { + if ((not $precision) || $precision !~ /^\d/) { + delete $result->{$col}{size}; + } + else { + my ($integer_datetimes) = $self->schema->storage->dbh + ->selectrow_array('show integer_datetimes'); + + my $max_precision = + $integer_datetimes =~ /^on\z/i ? 6 : 10; + + if ($precision == $max_precision) { + delete $result->{$col}{size}; + } + else { + $result->{$col}{size} = $precision; + } + } + } + elsif ((not $precision) || $precision !~ /^\d/ || $precision == 6) { delete $result->{$col}{size}; } else {