[plsql] Parentheses stopped working

Fixes #1828
This commit is contained in:
Andreas Dangel
2019-05-27 20:28:04 +02:00
parent c28c34e2f8
commit 8a57f3fdca
4 changed files with 27 additions and 3 deletions

View File

@ -16,6 +16,9 @@ This is a {{ site.pmd.release_type }} release.
### Fixed Issues
* plsql
* [#1828](https://github.com/pmd/pmd/issues/1828): \[plsql] Parentheses stopped working
### API Changes
### External Contributions

View File

@ -1440,11 +1440,11 @@ ASTCompoundCondition CompoundCondition() :
{}
{
(
LOOKAHEAD(3) "(" Condition() ")" (LOOKAHEAD(2) ( <AND> | <OR> ) { jjtThis.setType(token.getImage()); } Condition() )*
LOOKAHEAD(1) "(" Condition() ")" (LOOKAHEAD(2) ( <AND> | <OR> ) { jjtThis.setType(token.getImage()); } Condition() )*
|
LOOKAHEAD(3) <NOT> { jjtThis.setType(token.getImage()); } Condition()
LOOKAHEAD(1) <NOT> { jjtThis.setType(token.getImage()); } Condition()
|
LOOKAHEAD(3) Condition2() (LOOKAHEAD(2) ( <AND> | <OR> ) { jjtThis.setType(token.getImage()); } Condition() )*
Condition2() (LOOKAHEAD(2) ( <AND> | <OR> ) { jjtThis.setType(token.getImage()); } Condition() )*
)
{ return jjtThis; }
}

View File

@ -104,4 +104,11 @@ public class WhereClauseTest extends AbstractPLSQLParserTst {
StandardCharsets.UTF_8);
ASTInput input = parsePLSQL(code);
}
@Test
public void testParentheses() throws Exception {
String code = IOUtils.toString(this.getClass().getResourceAsStream("WhereClauseParens.pls"),
StandardCharsets.UTF_8);
parsePLSQL(code);
}
}

View File

@ -0,0 +1,14 @@
--
-- Where Clause With Parentheses
-- See https://github.com/pmd/pmd/issues/1828
--
BEGIN
select *
from dual
where (dummy = X or 1 = 2)
and 1=1;
END;
/