Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,12 @@ sub _extra_column_info {
if ($dbi_info->{mysql_values}) {
$extra_info{extra}{list} = $dbi_info->{mysql_values};
}

# TODO MariaDB docs say that the precision may be specified inside the
# brackets.
if ((not blessed $dbi_info) # isa $sth
&& lc($dbi_info->{COLUMN_DEF}) eq 'current_timestamp'
&& lc($dbi_info->{mysql_type_name}) eq 'timestamp') {
&& $dbi_info->{COLUMN_DEF} =~ m/^current_timestamp(?:\(\))?$/i
&& $dbi_info->{mysql_type_name} =~ m/^(?:timestamp|datetime)$/i) {

my $current_timestamp = 'current_timestamp';
$extra_info{default_value} = \$current_timestamp;
Expand Down
4 changes: 4 additions & 0 deletions t/10_02mysql_common.t
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ dbixcsl_common_tests->new(
'datetime' => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
'timestamp default current_timestamp'
=> { data_type => 'timestamp', default_value => \'current_timestamp', datetime_undef_if_invalid => 1 },
'timestamp not null default current_timestamp()'
=> { data_type => 'timestamp', default_value => \'current_timestamp', datetime_undef_if_invalid => 1 },
'datetime not null default current_timestamp()'
=> { data_type => 'datetime', default_value => \'current_timestamp', datetime_undef_if_invalid => 1 },
'time' => { data_type => 'time' },
'year' => { data_type => 'year' },
'year(4)' => { data_type => 'year' },
Expand Down