From: Rafael Kitover Date: Sat, 1 May 2010 21:20:50 +0000 (-0400) Subject: change CURRENT_TIMESTAMP to current_timestamp X-Git-Tag: 0.07000~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6e566cc4a06b1661597200611a03320f969e2566;p=dbsrgits%2FDBIx-Class-Schema-Loader.git change CURRENT_TIMESTAMP to current_timestamp --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index 886a45b..ed69925 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -131,7 +131,7 @@ sub _columns_info_for { } if (eval { lc ${ $info->{default_value} } }||'' eq 'current timestamp') { - ${ $info->{default_value} } = 'CURRENT_TIMESTAMP'; + ${ $info->{default_value} } = 'current_timestamp'; delete $info->{size}; } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm b/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm index 6cfb7ec..3dd27ca 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm @@ -293,6 +293,9 @@ EOF $info->{default_value} = $def =~ /^\d/ ? $def : \$def; } } + + ${ $info->{default_value} } = 'current_timestamp' + if ref $info->{default_value} && ${ $info->{default_value} } eq 'CURRENT_TIMESTAMP'; } return $result; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 7d65c44..d2847c3 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -281,7 +281,7 @@ wHERE lower(table_name) = @{[ $dbh->quote(lc $table) ]} AND lower(column_name) = $default =~ /^\d/ ? $default : \$default; if (eval { lc ${ $info->{default_value} } }||'' eq 'getdate()') { - ${ $info->{default_value} } = 'CURRENT_TIMESTAMP'; + ${ $info->{default_value} } = 'current_timestamp'; } } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index d8a8b9e..e8fb9de 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -205,10 +205,10 @@ EOF delete $result->{$col}{default_value}; } -# alias now() to CURRENT_TIMESTAMP for deploying to other DBs +# alias now() to current_timestamp for deploying to other DBs if (eval { lc ${ $result->{$col}{default_value} }||'' eq 'now()' }) { # do not use a ref to a constant, that breaks Data::Dump output - ${$result->{$col}{default_value}} = 'CURRENT_TIMESTAMP'; + ${$result->{$col}{default_value}} = 'current_timestamp'; } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm index 8cf364d..cc54ea7 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm @@ -107,7 +107,7 @@ EOF delete $info->{default_value} if ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } eq 'NULL'; if (eval { lc ${ $info->{default_value} } }||'' eq 'current timestamp') { - ${ $info->{default_value} } = 'CURRENT_TIMESTAMP'; + ${ $info->{default_value} } = 'current_timestamp'; } } diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 2e22729..e6e10ee 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -196,7 +196,8 @@ sub _extra_column_info { if ( lc($dbi_info->{COLUMN_DEF}) eq 'current_timestamp' && lc($dbi_info->{mysql_type_name}) eq 'timestamp') { - $extra_info{default_value} = \'CURRENT_TIMESTAMP'; + my $current_timestamp = 'current_timestamp'; + $extra_info{default_value} = \$current_timestamp; } return \%extra_info; diff --git a/t/11mysql_common.t b/t/11mysql_common.t index 48208b9..84339ce 100644 --- a/t/11mysql_common.t +++ b/t/11mysql_common.t @@ -90,8 +90,8 @@ my $tester = dbixcsl_common_tests->new( # Date and Time Types 'date' => { data_type => 'date' }, 'datetime' => { data_type => 'datetime' }, - 'timestamp DEFAULT current_timestamp' - => { data_type => 'timestamp', default_value => \"CURRENT_TIMESTAMP" }, + 'timestamp default current_timestamp' + => { data_type => 'timestamp', default_value => \'current_timestamp' }, 'time' => { data_type => 'time' }, 'year' => { data_type => 'year' }, 'year(4)' => { data_type => 'year' }, diff --git a/t/12pg_common.t b/t/12pg_common.t index 3b626b1..5693c89 100644 --- a/t/12pg_common.t +++ b/t/12pg_common.t @@ -57,7 +57,7 @@ my $tester = dbixcsl_common_tests->new( 'time(2) with time zone' => { size => 2, data_type => 'time with time zone' }, timestamp => { data_type => 'timestamp without time zone' }, 'timestamp default current_timestamp' - => { data_type => 'timestamp without time zone', default_value => \'CURRENT_TIMESTAMP' }, + => { data_type => 'timestamp without time zone', default_value => \'current_timestamp' }, 'timestamp(2)' => { size => 2, data_type => 'timestamp without time zone' }, 'timestamp without time zone' => { data_type => 'timestamp without time zone' }, 'timestamp(2) without time zone' => { size => 2, data_type => 'timestamp without time zone' }, diff --git a/t/13db2_common.t b/t/13db2_common.t index 6a7f17c..c21fec8 100644 --- a/t/13db2_common.t +++ b/t/13db2_common.t @@ -14,7 +14,7 @@ my $tester = dbixcsl_common_tests->new( password => $password, null => '', data_types => { - 'timestamp DEFAULT CURRENT TIMESTAMP' => { data_type => 'timestamp', default_value => \'CURRENT_TIMESTAMP' } + 'timestamp default current timestamp' => { data_type => 'timestamp', default_value => \'current_timestamp' } }, ); diff --git a/t/16mssql_common.t b/t/16mssql_common.t index 31c373a..305fe5b 100644 --- a/t/16mssql_common.t +++ b/t/16mssql_common.t @@ -67,9 +67,9 @@ my $tester = dbixcsl_common_tests->new( # datetime types date => { data_type => 'date' }, datetime => { data_type => 'datetime' }, - # test rewriting getdate() to CURRENT_TIMESTAMP - 'datetime DEFAULT getdate()' - => { data_type => 'datetime', default_value => \'CURRENT_TIMESTAMP' }, + # test rewriting getdate() to current_timestamp + 'datetime default getdate()' + => { data_type => 'datetime', default_value => \'current_timestamp' }, smalldatetime => { data_type => 'smalldatetime' }, time => { data_type => 'time' }, 'time(0)'=> { data_type => 'time', size => 0 }, diff --git a/t/17sybase_asa_common.t b/t/17sybase_asa_common.t index 1d3495d..f85bf34 100644 --- a/t/17sybase_asa_common.t +++ b/t/17sybase_asa_common.t @@ -91,9 +91,9 @@ my $tester = dbixcsl_common_tests->new( 'smalldatetime' => { data_type => 'smalldatetime' }, 'timestamp' => { data_type => 'timestamp' }, - # rewrite 'current timestamp' as 'CURRENT_TIMESTAMP' - 'timestamp DEFAULT current timestamp' - => { data_type => 'timestamp', default_value => \"CURRENT_TIMESTAMP" }, + # rewrite 'current timestamp' as 'current_timestamp' + 'timestamp default current timestamp' + => { data_type => 'timestamp', default_value => \'current_timestamp' }, 'time' => { data_type => 'time' }, # String Types diff --git a/t/18firebird_common.t b/t/18firebird_common.t index 94342cf..d73f4e9 100644 --- a/t/18firebird_common.t +++ b/t/18firebird_common.t @@ -94,8 +94,8 @@ my $tester = dbixcsl_common_tests->new( # Date and Time Types 'date' => { data_type => 'date' }, - 'timestamp DEFAULT CURRENT_TIMESTAMP' - => { data_type => 'timestamp', default_value => \"CURRENT_TIMESTAMP" }, + 'timestamp default current_timestamp' + => { data_type => 'timestamp', default_value => \'current_timestamp' }, 'time' => { data_type => 'time' }, # String Types diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index ab6d8cb..7b83ea9 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -45,8 +45,8 @@ sub new { $self->{date_datatype} ||= 'DATE'; # Not all DBS do SQL-standard CURRENT_TIMESTAMP - $self->{default_function} ||= "CURRENT_TIMESTAMP"; - $self->{default_function_def} ||= "TIMESTAMP DEFAULT $self->{default_function}"; + $self->{default_function} ||= "current_timestamp"; + $self->{default_function_def} ||= "timestamp default $self->{default_function}"; $self = bless $self, $class;