Skip to content

Commit f61aa25

Browse files
committed
support for value lists in enum & set field defs
1 parent 76a23ac commit f61aa25

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

lib_sql_parser.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ function parse_field($tokens){
574574
case 'ENUM':
575575
case 'SET':
576576

577-
# values
577+
$f['values'] = $this->parse_value_list($tokens);
578578
$this->parse_field_charset($tokens, $f);
579579
$this->parse_field_collate($tokens, $f);
580580
break;
@@ -888,6 +888,33 @@ function parse_field_collate(&$tokens, &$f){
888888
}
889889
}
890890

891+
function parse_value_list(&$tokens){
892+
if ($tokens[0] != '(') return null;
893+
array_shift($tokens);
894+
895+
$values = array();
896+
while (count($tokens)){
897+
898+
if ($tokens[0] == ')'){
899+
array_shift($tokens);
900+
return $values;
901+
}
902+
903+
$values[] = $this->decode_value(array_shift($tokens));
904+
905+
if ($tokens[0] == ')'){
906+
array_shift($tokens);
907+
return $values;
908+
}
909+
910+
if ($tokens[0] == ','){
911+
array_shift($tokens);
912+
}else{
913+
# error
914+
return $values;
915+
}
916+
}
917+
}
891918

892919
function decode_identifier($token){
893920
if ($token[0] == '`'){

0 commit comments

Comments
 (0)