From: Jess Robinson Date: Mon, 20 Oct 2008 15:30:53 +0000 (+0000) Subject: Patches for/with jgoulah: X-Git-Tag: v0.11008~292 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=531652d6a65d2f990c431008ee44c3f8ca853d95;hp=3edb144c0fd279430e3688243ca942c85a96009a;p=dbsrgits%2FSQL-Translator.git Patches for/with jgoulah: - make mysql parser match anything as a col/table name when quoted - add support for spatial index parsing --- diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index d657475..a8793f6 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -534,6 +534,7 @@ reference_option: /restrict/i | index : normal_index | fulltext_index + | spatial_index | table_name : NAME @@ -680,6 +681,16 @@ fulltext_index : /fulltext/i KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) } } +spatial_index : /spatial/i KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) ')' + { + $return = { + supertype => 'index', + type => 'spatial', + name => $item{'index_name(?)'}[0], + fields => $item[5], + } + } + name_with_opt_paren : NAME parens_value_list(s?) { $item[2][0] ? "$item[1]($item[2][0][0])" : $item[1] } @@ -727,7 +738,7 @@ COMMA : ',' BACKTICK : '`' -NAME : BACKTICK /\w+/ BACKTICK +NAME : BACKTICK /[^`]+/ BACKTICK { $item[2] } | /\w+/ { $item[1] } diff --git a/lib/SQL/Translator/Schema/Constants.pm b/lib/SQL/Translator/Schema/Constants.pm index 95fa2a6..a201557 100644 --- a/lib/SQL/Translator/Schema/Constants.pm +++ b/lib/SQL/Translator/Schema/Constants.pm @@ -69,6 +69,7 @@ $VERSION = sprintf "%d.%02d", q$Revision: 1.43 $ =~ /(\d+)\.(\d+)/; CHECK_C FOREIGN_KEY FULL_TEXT + SPATIAL NOT_NULL NORMAL NULL @@ -85,6 +86,8 @@ use constant FOREIGN_KEY => 'FOREIGN KEY'; use constant FULL_TEXT => 'FULLTEXT'; +use constant SPATIAL => 'SPATIAL'; + use constant NOT_NULL => 'NOT NULL'; use constant NORMAL => 'NORMAL'; diff --git a/lib/SQL/Translator/Schema/Index.pm b/lib/SQL/Translator/Schema/Index.pm index 4a5237e..6c75361 100644 --- a/lib/SQL/Translator/Schema/Index.pm +++ b/lib/SQL/Translator/Schema/Index.pm @@ -59,6 +59,7 @@ my %VALID_INDEX_TYPE = ( UNIQUE, 1, NORMAL, 1, FULL_TEXT, 1, # MySQL only (?) + SPATIAL, 1, # MySQL only (?) ); # ----------------------------------------------------------------------