Subject: | return scalar ref for default current_timestamp regardless of case |
Sqlt-parser-mysql is written to parse a default value of
'CURRENT_TIMESTAMP' and return it as a ref in column_info, per the
following entry from the changelog:
# ----------------------------------------------------------
# 0.09002 2008-12-05
# ----------------------------------------------------------
* parsing MySQL CURRENT_TIMESTAMP as scalar ref so it can be produced
without quotes (jgoulah)
However this logic fails if the SQL is written in lower case. This
will cause spurious diffs against columns with a default of
'current_timestamp', for example when using with dbix-class for migrations.
This patch fixes the parser so that it matches current_timestamp for
defaults in a case-insensitive manner, and stores them as a ref in
column info in either case.
Subject: | sqlt-parser-mysql-current-timestamp.patch |
diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm
index 60a8602..531be84 100644
--- a/lib/SQL/Translator/Parser/MySQL.pm
+++ b/lib/SQL/Translator/Parser/MySQL.pm
@@ -484,7 +484,7 @@ field_qualifier : /collate/i WORD
}
}
-field_qualifier : /on update/i 'CURRENT_TIMESTAMP'
+field_qualifier : /on update/i /\bCURRENT_TIMESTAMP\b/i
{
$return = {
'ON UPDATE' => $item[2],