Merge branch 'pr-1885'
This commit is contained in:
@ -16,7 +16,7 @@ This is a {{ site.pmd.release_type }} release.
|
|||||||
|
|
||||||
#### PLSQL Grammar Updates
|
#### PLSQL Grammar Updates
|
||||||
|
|
||||||
The grammar has been updated to support Inline Constraints in CREATE TABLE statements. Additionally, the
|
The grammar has been updated to support inline constraints in CREATE TABLE statements. Additionally, the
|
||||||
CREATE TABLE statement may now be followed by physical properties and table properties. However, these
|
CREATE TABLE statement may now be followed by physical properties and table properties. However, these
|
||||||
properties are skipped over during parsing.
|
properties are skipped over during parsing.
|
||||||
|
|
||||||
@ -25,6 +25,8 @@ The CREATE VIEW statement now supports subquery views.
|
|||||||
The EXTRACT function can now be parsed correctly. It is used to extract values from a specified
|
The EXTRACT function can now be parsed correctly. It is used to extract values from a specified
|
||||||
datetime field. Also date time literals are parsed now correctly.
|
datetime field. Also date time literals are parsed now correctly.
|
||||||
|
|
||||||
|
The CASE expression can now be properly used within SELECT statements.
|
||||||
|
|
||||||
#### New Rules
|
#### New Rules
|
||||||
|
|
||||||
* The Java rule {% rule "java/bestpractices/DoubleBraceInitialization" %} (`java-bestpractices`)
|
* The Java rule {% rule "java/bestpractices/DoubleBraceInitialization" %} (`java-bestpractices`)
|
||||||
@ -117,6 +119,7 @@ of deprecations.
|
|||||||
* [#1876](https://github.com/pmd/pmd/pull/1876): \[plsql] Datetime support for queries - [Hugo Araya Nash](https://github.com/kabroxiko)
|
* [#1876](https://github.com/pmd/pmd/pull/1876): \[plsql] Datetime support for queries - [Hugo Araya Nash](https://github.com/kabroxiko)
|
||||||
* [#1883](https://github.com/pmd/pmd/pull/1883): \[plsql] Fix #1873 Expression list not working - [Hugo Araya Nash](https://github.com/kabroxiko)
|
* [#1883](https://github.com/pmd/pmd/pull/1883): \[plsql] Fix #1873 Expression list not working - [Hugo Araya Nash](https://github.com/kabroxiko)
|
||||||
* [#1884](https://github.com/pmd/pmd/pull/1884): \[plsql] fix #1878 Support explicit INNER word for INNER JOIN - [Hugo Araya Nash](https://github.com/kabroxiko)
|
* [#1884](https://github.com/pmd/pmd/pull/1884): \[plsql] fix #1878 Support explicit INNER word for INNER JOIN - [Hugo Araya Nash](https://github.com/kabroxiko)
|
||||||
|
* [#1885](https://github.com/pmd/pmd/pull/1885): \[plsql] Correct case expression - [Hugo Araya Nash](https://github.com/kabroxiko)
|
||||||
|
|
||||||
{% endtocmaker %}
|
{% endtocmaker %}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various fixes for expression lists, join clauses
|
* Various fixes for expression lists, join clauses, case expression
|
||||||
*
|
*
|
||||||
* Hugo Araya Nash 06/2019
|
* Hugo Araya Nash 06/2019
|
||||||
*====================================================================
|
*====================================================================
|
||||||
@ -2870,24 +2870,14 @@ ASTAssignment Assignment() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASTCaseExpression CaseExpression() :
|
ASTCaseExpression CaseExpression() :
|
||||||
{ Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; }
|
{}
|
||||||
{
|
{
|
||||||
(
|
<CASE>
|
||||||
thisToken = <CASE> { sb.append(thisToken.image);}
|
( Expression() ( <WHEN> Expression() <THEN> Expression() )+
|
||||||
( simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } )?
|
| ( <WHEN> Condition() <THEN> Expression() )+ )
|
||||||
( thisToken = <WHEN> { sb.append(" "); sb.append(thisToken.image); }
|
[ <ELSE> Expression() ]
|
||||||
simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); }
|
<END>
|
||||||
thisToken = <THEN> { sb.append(" "); sb.append(thisToken.image); }
|
{ return jjtThis; }
|
||||||
Expression() { sb.append(" "); sb.append(simpleNode.getImage()); }
|
|
||||||
)+
|
|
||||||
[ thisToken = <ELSE> { sb.append(" "); sb.append(thisToken.image);}
|
|
||||||
Expression() { sb.append(" "); sb.append(simpleNode.getImage()); }
|
|
||||||
]
|
|
||||||
thisToken = <END> { sb.append(" "); sb.append(thisToken.image);}
|
|
||||||
)
|
|
||||||
{
|
|
||||||
jjtThis.setImage(sb.toString()); return jjtThis;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3260,7 +3250,7 @@ ASTPrimaryPrefix PrimaryPrefix() :
|
|||||||
// Note: AnalyticClause and WithinClause are only allowed for specific functions, but this grammar allows it for all functions.
|
// Note: AnalyticClause and WithinClause are only allowed for specific functions, but this grammar allows it for all functions.
|
||||||
LOOKAHEAD(FunctionName() "(") ( simpleNode = FunctionCall() [ AnalyticClause() ] [ WithinClause() ] ) { sb.append(simpleNode.getImage()); }
|
LOOKAHEAD(FunctionName() "(") ( simpleNode = FunctionCall() [ AnalyticClause() ] [ WithinClause() ] ) { sb.append(simpleNode.getImage()); }
|
||||||
| LOOKAHEAD(MultiSetCondition()) simpleNode = MultiSetCondition()
|
| LOOKAHEAD(MultiSetCondition()) simpleNode = MultiSetCondition()
|
||||||
| LOOKAHEAD(CaseExpression()) ( simpleNode =CaseExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110520
|
| LOOKAHEAD(<CASE>) ( simpleNode =CaseExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110520
|
||||||
| LOOKAHEAD(ObjectExpression() ) ( simpleNode = ObjectExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110604
|
| LOOKAHEAD(ObjectExpression() ) ( simpleNode = ObjectExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110604
|
||||||
//| LOOKAHEAD(LikeExpression()) ( simpleNode = LikeExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110604
|
//| LOOKAHEAD(LikeExpression()) ( simpleNode = LikeExpression() ) { sb.append(simpleNode.getImage()) ; } //SRT 20110604
|
||||||
| LOOKAHEAD(Literal()) ( simpleNode = Literal() ) { sb.append(simpleNode.getImage()) ; }
|
| LOOKAHEAD(Literal()) ( simpleNode = Literal() ) { sb.append(simpleNode.getImage()) ; }
|
||||||
|
@ -84,5 +84,28 @@ SELECT CASE
|
|||||||
INTO my_result
|
INTO my_result
|
||||||
FROM DUAL;
|
FROM DUAL;
|
||||||
|
|
||||||
|
SELECT CASE WHEN EXISTS(SELECT *
|
||||||
|
FROM DUAL
|
||||||
|
WHERE 1 = 1)
|
||||||
|
THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END isExists
|
||||||
|
INTO VAL
|
||||||
|
FROM dual;
|
||||||
|
|
||||||
|
SELECT CASE WHEN EXISTS(SELECT *
|
||||||
|
FROM DUAL)
|
||||||
|
THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END isExists
|
||||||
|
INTO VAL
|
||||||
|
FROM dual;
|
||||||
|
|
||||||
|
SELECT CASE
|
||||||
|
WHEN f1(x) IS NULL THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END isExists
|
||||||
|
INTO VAL
|
||||||
|
FROM dual;
|
||||||
END;
|
END;
|
||||||
/
|
/
|
Reference in New Issue
Block a user