From: John Goulah Date: Mon, 1 Dec 2008 17:26:36 +0000 (+0000) Subject: add param to _apply_default_value so that certain values can output without quotes X-Git-Tag: v0.11008~274 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5c1ffcdc2b0bde9c637ff63581fed2bb8b67266e;p=dbsrgits%2FSQL-Translator.git add param to _apply_default_value so that certain values can output without quotes --- diff --git a/Changes b/Changes index 07d93c8..87362a1 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ # ---------------------------------------------------------- # # ---------------------------------------------------------- +* Add param to _apply_default_value so that certain values can output without quotes (jgoulah) * Add ignore_opts parser arg (to ignore table options) in Parser::MySQL (jgoulah) * Skip tests for buggy Spreadsheet::ParseExcel versions (rbo) * Add support for skip tables parser arg in Parser::DBI::MySQL (jgoulah) diff --git a/lib/SQL/Translator/Producer.pm b/lib/SQL/Translator/Producer.pm index 3366dc1..3fccfc9 100644 --- a/lib/SQL/Translator/Producer.pm +++ b/lib/SQL/Translator/Producer.pm @@ -34,7 +34,9 @@ sub produce { "" } ## They are special per Producer, and provide support for the old 'now()' ## default value exceptions sub _apply_default_value { - my (undef, $field_ref, $default, $exceptions) = @_; + my (undef, $field_ref, $default, $exceptions, $noquote) = @_; + + my @noquote = (defined $noquote)?@$noquote:(); if ($exceptions and ! ref $default) { for (my $i = 0; $i < @$exceptions; $i += 2) { @@ -49,10 +51,11 @@ sub _apply_default_value { } } + my $qc = (grep m/$default/, @noquote)?"":"'"; if (ref $default) { $$field_ref .= " DEFAULT $$default"; } else { - $$field_ref .= " DEFAULT '$default'"; + $$field_ref .= " DEFAULT $qc$default$qc"; } } diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 3ce2c38..8d6b6e6 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -566,6 +566,9 @@ sub create_field [ 'NULL' => \'NULL', ], + [ + 'CURRENT_TIMESTAMP' + ], ); }