@@ -1622,7 +1622,7 @@ on_clause
16221622 = KW_ON __ e :expr { return e; }
16231623
16241624where_clause
1625- = KW_WHERE __ e :( or_and_where_expr / expr ) { return e; }
1625+ = KW_WHERE __ e :or_and_where_expr { return e; }
16261626
16271627group_by_clause
16281628 = KW_GROUP __ KW_BY __ e :expr_list { return e .value ; }
@@ -1893,14 +1893,25 @@ interval_expr
18931893
18941894case_expr
18951895 = KW_CASE __
1896- expr :expr ? __
18971896 condition_list :case_when_then + __
18981897 otherwise :case_else ? __
18991898 KW_END __ KW_CASE ? {
19001899 if (otherwise) condition_list .push (otherwise);
19011900 return {
19021901 type: ' case' ,
1903- expr: expr || null ,
1902+ expr: null ,
1903+ args: condition_list
1904+ };
1905+ }
1906+ / KW_CASE __
1907+ expr :expr __
1908+ condition_list :case_when_then + __
1909+ otherwise :case_else ? __
1910+ KW_END __ KW_CASE ? {
1911+ if (otherwise) condition_list .push (otherwise);
1912+ return {
1913+ type: ' case' ,
1914+ expr: expr,
19041915 args: condition_list
19051916 };
19061917 }
@@ -1948,7 +1959,7 @@ unary_expr
19481959 }
19491960
19501961or_and_where_expr
1951- = head :parentheses_or_expr tail :(__ (KW_AND / KW_OR ) __ parentheses_or_expr )* {
1962+ = head :expr tail :(__ (KW_AND / KW_OR ) __ expr )* {
19521963 return createBinaryExprChain (head, tail);
19531964}
19541965
@@ -1960,13 +1971,7 @@ or_expr
19601971and_expr
19611972 = head :not_expr tail :(___ KW_AND __ not_expr )* {
19621973 return createBinaryExprChain (head, tail);
1963- }
1964- parentheses_or_expr
1965- = lf :LPAREN __ head :or_expr __ rt :RPAREN {
1966- head .parentheses = true
1967- return head
19681974 }
1969- / or_expr
19701975//here we should use `NOT` instead of `comparision_expr` to support chain-expr
19711976not_expr
19721977 = comparison_expr
@@ -2913,10 +2918,15 @@ data_type
29132918 / text_type
29142919 / enum_type
29152920 / boolean_type
2921+ / binary_type
29162922
29172923boolean_type
29182924 = 'boolean' i { return { dataType: ' BOOLEAN' }; }
29192925
2926+ binary_type
2927+ = 'binary' i { return { dataType: ' BINARY' }; }
2928+ / 'varbinary' i { return { dataType: ' VARBINARY' }; }
2929+
29202930character_string_type
29212931 = t :(KW_CHAR / KW_VARCHAR ) __ LPAREN __ l :[0-9]+ __ RPAREN {
29222932 return { dataType: t, length: parseInt (l .join (' ' ), 10 ) };
0 commit comments