From: Dagfinn Ilmari Mannsåker Date: Tue, 12 Sep 2017 10:37:33 +0000 (+0100) Subject: Fix 'default now()' test for PostgreSQL v10 X-Git-Tag: 0.07048~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=ed566bb0b00fe6ad9493c12c5dc5242d326ed48f Fix 'default now()' test for PostgreSQL v10 It upcases default_timestamp in default values, so make sure they are downcased again for consistency with other loaders. --- diff --git a/Changes b/Changes index ba6ff49..3fc6f80 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader - Fix for PostgreSQL enums not in the schema search path (RT#123234) + - Fix 'default now()' test for PostgreSQL v10 0.07047 2017-05-26 - Avoid upcoming DBIC warning on implicit SELECT * invocation diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index b614919..a0d6dff 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -323,6 +323,10 @@ EOF my $now = 'now()'; $info->{original}{default_value} = \$now; } + elsif (${ $info->{default_value} } =~ /\bCURRENT_TIMESTAMP\b/) { + # PostgreSQL v10 upcases current_timestamp in default values + ${ $info->{default_value} } =~ s/\b(CURRENT_TIMESTAMP)\b/lc $1/ge; + } } # detect 0/1 for booleans and rewrite