MySQL-Workbench-Parser
view release on metacpan or search on metacpan
lib/MySQL/Workbench/Parser/MySQLParser.pm view on Meta::CPAN
$return = {
COLLATE => $item[2],
}
}
field_qualifier : /on update/i CURRENT_TIMESTAMP
{
$return = {
'ON UPDATE' => $item[2],
}
}
field_qualifier : /unique/i KEY(?)
{
$return = {
is_unique => 1,
}
}
field_qualifier : KEY
{
$return = {
has_index => 1,
}
}
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 = {
type => 'foreign_key',
reference_table => $item[2],
reference_fields => $item[3][0],
match_type => $item[4][0],
on_delete => $item[5][0],
on_update => $item[6][0],
}
}
match_type : /match full/i { 'full' }
|
/match partial/i { 'partial' }
on_delete : /on delete/i reference_option
{ $item[2] }
on_update :
/on update/i CURRENT_TIMESTAMP
{ $item[2] }
|
/on update/i reference_option
{ $item[2] }
reference_option: /restrict/i |
/cascade/i |
/set null/i |
/no action/i |
/set default/i
{ $item[1] }
index : normal_index
| fulltext_index
| spatial_index
| <error>
table_name : NAME
field_name : NAME
index_name : NAME
data_type : WORD parens_value_list(s?) type_qualifier(s?)
{
my $type = $item[1];
my $size; # field size, applicable only to non-set fields
my $list; # set list, applicable only to sets (duh)
if ( uc($type) =~ /^(SET|ENUM)$/ ) {
$size = undef;
$list = $item[2][0];
}
else {
$size = $item[2][0];
$list = [];
}
$return = {
type => $type,
size => $size,
list => $list,
qualifiers => $item[3],
}
}
parens_field_list : '(' field_name(s /,/) ')'
{ $item[2] }
parens_value_list : '(' VALUE(s /,/) ')'
{ $item[2] }
type_qualifier : /(BINARY|UNSIGNED|ZEROFILL)/i
{ lc $item[1] }
field_type : WORD
create_index : /create/i /index/i
not_null : /not/i /null/i
{ $return = 0 }
|
/null/i
{ $return = 1 }
unsigned : /unsigned/i { $return = 0 }
( run in 0.898 second using v1.01-cache-2.11-cpan-39bf76dae61 )