@@ -, +, @@ --- misc/devel/update_dbix_class_files.pl | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) --- a/misc/devel/update_dbix_class_files.pl +++ a/misc/devel/update_dbix_class_files.pl @@ -20,6 +20,7 @@ use Modern::Perl; +use Sub::Override; use DBIx::Class::Schema::Loader qw/ make_schema_at /; use Getopt::Long; @@ -91,6 +92,39 @@ $db_name //= $db_defaults{name}; $db_user //= $db_defaults{user}; $db_passwd //= $db_defaults{passwd}; +# This is being upstreamed, but for now lets make sure whatever version of DBIx::Class::Schema::Loader you are using, +# we will catch MariaDB current_timestamp() and convert it to \"current_timestamp" correctly. +my $override = Sub::Override->new( + 'DBIx::Class::Schema::Loader::DBI::mysql::_extra_column_info', + sub { + no warnings 'uninitialized'; + my ( $self, $table, $col, $info, $dbi_info ) = @_; + my %extra_info; + + if ( $dbi_info->{mysql_is_auto_increment} ) { + $extra_info{is_auto_increment} = 1; + } + if ( $dbi_info->{mysql_type_name} =~ /\bunsigned\b/i ) { + $extra_info{extra}{unsigned} = 1; + } + if ( $dbi_info->{mysql_values} ) { + $extra_info{extra}{list} = $dbi_info->{mysql_values}; + } + if ( + ( not blessed $dbi_info) # isa $sth + && lc( $dbi_info->{COLUMN_DEF} ) =~ m/^current_timestamp/ + && lc( $dbi_info->{mysql_type_name} ) eq 'timestamp' + ) + { + + my $current_timestamp = 'current_timestamp'; + $extra_info{default_value} = \$current_timestamp; + } + + return \%extra_info; + } +); + if (! defined $db_name ) { print "Error: \'db_name\' parameter is mandatory.\n"; pod2usage(1); --