From: John Goulah Date: Tue, 2 Dec 2008 15:15:39 +0000 (+0000) Subject: reverting r1413 and r1414 in favor of passing a scalar ref to parser which the produc... X-Git-Tag: v0.11008~272 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0f4c1a5b19afcf629ad864399518bc96bf0faabf;p=dbsrgits%2FSQL-Translator.git reverting r1413 and r1414 in favor of passing a scalar ref to parser which the producer outputs correctly without quotes --- diff --git a/Changes b/Changes index 87362a1..e4ff8ba 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,7 @@ # ---------------------------------------------------------- # # ---------------------------------------------------------- -* Add param to _apply_default_value so that certain values can output without quotes (jgoulah) +* parsing MySQL CURRENT_TIMESTAMP as scalar ref so it can be produced 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/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 804c9a1..41d969e 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -597,7 +597,7 @@ unsigned : /unsigned/i { $return = 0 } default_val : /default/i 'CURRENT_TIMESTAMP' { - $return = $item[2]; + $return = \$item[2]; } | /default/i /'(?:.*?\\')*.*?'|(?:')?[\w\d:.-]*(?:')?/ diff --git a/lib/SQL/Translator/Producer.pm b/lib/SQL/Translator/Producer.pm index 9f4d3d0..3366dc1 100644 --- a/lib/SQL/Translator/Producer.pm +++ b/lib/SQL/Translator/Producer.pm @@ -34,9 +34,7 @@ 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, $noquote) = @_; - - my @noquote = (defined $noquote)?@$noquote:(); + my (undef, $field_ref, $default, $exceptions) = @_; if ($exceptions and ! ref $default) { for (my $i = 0; $i < @$exceptions; $i += 2) { @@ -51,11 +49,10 @@ sub _apply_default_value { } } - my $qc = (grep m/^$default$/, @noquote)?"":"'"; if (ref $default) { $$field_ref .= " DEFAULT $$default"; } else { - $$field_ref .= " DEFAULT $qc$default$qc"; + $$field_ref .= " DEFAULT '$default'"; } } diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 8d6b6e6..3ce2c38 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -566,9 +566,6 @@ sub create_field [ 'NULL' => \'NULL', ], - [ - 'CURRENT_TIMESTAMP' - ], ); }