[plsql] Add support for 'DEFAULT' clause on the arguments of some oracle functions (#5088)

Merge pull request #5088 from duursma:DEFAULT_ARGUMENT
This commit is contained in:
Andreas Dangel 2024-07-11 10:33:18 +02:00
commit adfb9568b7
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
6 changed files with 925 additions and 8 deletions

View File

@ -18,12 +18,14 @@ This is a {{ site.pmd.release_type }} release.
* plsql
* [#5086](https://github.com/pmd/pmd/pull/5086): \[plsql] Fixed issue with missing optional table alias in MERGE usage
* [#5087](https://github.com/pmd/pmd/pull/5087): \[plsql] Add support for SQL_MACRO
* [#5088](https://github.com/pmd/pmd/pull/5088): \[plsql] Add support for 'DEFAULT' clause on the arguments of some oracle functions
### 🚨 API Changes
### ✨ External Contributions
* [#5086](https://github.com/pmd/pmd/pull/5086): \[plsql] Fixed issue with missing optional table alias in MERGE usage - [Arjen Duursma](https://github.com/duursma) (@duursma)
* [#5087](https://github.com/pmd/pmd/pull/5087): \[plsql] Add support for SQL_MACRO - [Arjen Duursma](https://github.com/duursma) (@duursma)
* [#5088](https://github.com/pmd/pmd/pull/5088): \[plsql] Add support for 'DEFAULT' clause on the arguments of some oracle functions - [Arjen Duursma](https://github.com/duursma) (@duursma)
{% endtocmaker %}

View File

@ -3872,10 +3872,13 @@ ASTArgument Argument() :
{
//[LOOKAHEAD(2) UnqualifiedID() "=>"] Expression()
[LOOKAHEAD(2) (simpleNode = UnqualifiedID()) ("=>" | <AS> ) ]
(Expression() )
Expression()
// e.g. TO_NUMBER allows a DEFAULT clause within an argument
// https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/TO_NUMBER.html#GUID-D4807212-AFD7-48A7-9AED-BEC3E8809866
[ <_DEFAULT> Expression() <ON> KEYWORD("CONVERSION") "ERROR" ]
//Allow Using CharacterSet suffix clause
[
( <USING> )
<USING>
( <CHAR_CS> | <NCHAR_CS> )
]
{

View File

@ -66,4 +66,9 @@ class PlsqlTreeDumpTest extends BaseTreeDumpTest {
void sqlMacroClause() {
doTest("SqlMacroClause");
}
@Test
void parseSelectExpression() {
doTest("SelectExpressions");
}
}

View File

@ -15,11 +15,6 @@ import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
class SelectExpressionsTest extends AbstractPLSQLParserTst {
@Test
void parseSelectExpression() {
plsql.parseResource("SelectExpressions.pls");
}
@Test
void parseSelectSimpleExpression() {
ASTInput input = plsql.parseResource("SelectSimpleExpression.pls");

View File

@ -108,4 +108,11 @@ SELECT CASE
INTO VAL
FROM dual;
END;
/
SELECT
TO_NUMBER$('xyz' default 0 on conversion error) BOGUS
INTO some_record
FROM some_table;
/