X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FMySQL.pm;h=46085e33b0c1e86527a83f00cf9e212f66a221cd;hb=HEAD;hp=8cdd7948ded85038c987dd51192a1248f257f885;hpb=fd498bb0acde8fb312f841aaebc896ed19db59d1;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index 8cdd794..46085e3 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -132,7 +132,7 @@ More information about the MySQL comment-syntax: L 'field', @@ -578,6 +575,13 @@ field_qualifier : KEY } } +field_qualifier : /comment/i string + { + $return = { + comment => $item[2], + } + } + reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete(?) on_update(?) { $return = { @@ -688,6 +692,11 @@ default_val : { $return = $item[2]; } + | + /default/i NAME # column value, allowed in MariaDB + { + $return = $item[2]; + } auto_inc : /auto_increment/i { 1 } @@ -696,8 +705,31 @@ primary_key : /primary/i /key/i { 1 } constraint : primary_key_def | unique_key_def | foreign_key_def + | check_def | +expr : /[^)]* \( [^)]+ \) [^)]*/x # parens, balanced one deep + | /[^)]+/ + +check_def : check_def_begin '(' expr ')' + { + $return = { + supertype => 'constraint', + type => 'check', + name => $item[1], + expression => $item[3], + } + } + +check_def_begin : /constraint/i /check/i NAME + { $return = $item[3] } + | + /constraint/i NAME /check/i + { $return = $item[2] } + | + /constraint/i /check/i + { $return = '' } + foreign_key_def : foreign_key_def_begin parens_field_list reference_definition { $return = { @@ -1013,6 +1045,7 @@ sub parse { name => $cdata->{'name'}, type => $cdata->{'type'}, fields => $cdata->{'fields'}, + expression => $cdata->{'expression'}, reference_table => $cdata->{'reference_table'}, reference_fields => $cdata->{'reference_fields'}, match_type => $cdata->{'match_type'} || '',