Skip to content

Commit

Permalink
CDR-1175 Fix parsing of string function CONTAINS
Browse files Browse the repository at this point in the history
  • Loading branch information
vmueller-vg committed Dec 13, 2023
1 parent 637e3b8 commit 5ef1eca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Expand Up @@ -90,7 +90,7 @@ LIKE: L I K E ;
MATCHES: M A T C H E S ;

// functions
STRING_FUNCTION_ID: LENGTH | CONTAINS | POSITION | SUBSTRING | CONCAT_WS | CONCAT ;
STRING_FUNCTION_ID: LENGTH | POSITION | SUBSTRING | CONCAT_WS | CONCAT ;
NUMERIC_FUNCTION_ID: ABS | MOD | CEIL | FLOOR | ROUND ;
DATE_TIME_FUNCTION_ID: NOW | CURRENT_DATE_TIME | CURRENT_DATE | CURRENT_TIMEZONE | CURRENT_TIME ;
// string functions
Expand Down
Expand Up @@ -207,7 +207,7 @@ numericPrimitive

functionCall
: terminologyFunction
| name=(STRING_FUNCTION_ID | NUMERIC_FUNCTION_ID | DATE_TIME_FUNCTION_ID | IDENTIFIER) SYM_LEFT_PAREN (terminal (SYM_COMMA terminal)*)? SYM_RIGHT_PAREN
| name=(CONTAINS | STRING_FUNCTION_ID | NUMERIC_FUNCTION_ID | DATE_TIME_FUNCTION_ID | IDENTIFIER) SYM_LEFT_PAREN (terminal (SYM_COMMA terminal)*)? SYM_RIGHT_PAREN
;

aggregateFunctionCall
Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentClassExpression;
import org.ehrbase.openehr.sdk.aql.dto.containment.ContainmentSetOperator;
import org.ehrbase.openehr.sdk.aql.dto.operand.AggregateFunction.AggregateFunctionName;
import org.ehrbase.openehr.sdk.aql.dto.operand.SingleRowFunction.KnownFunctionName;
import org.ehrbase.openehr.sdk.aql.dto.operand.StringPrimitive;
import org.ehrbase.openehr.sdk.aql.dto.path.AndOperatorPredicate;
import org.ehrbase.openehr.sdk.aql.dto.path.AqlObjectPath;
Expand Down Expand Up @@ -438,6 +439,20 @@ void testAggregateFunctions(AggregateFunctionName name) {
testAql(aql, aql);
}

@ParameterizedTest
@EnumSource(KnownFunctionName.class)
void testKnownSingleRowFunctions(KnownFunctionName name) {
// Argument count does not matter to the grammar
String aql = "SELECT " + name.name() + "() FROM EHR d";
testAql(aql, aql);
}

@Test
void testUnknownSingleRowFunctions() {
String aql = "SELECT CUSTOM_FUNCTION() FROM EHR d";
testAql(aql, aql);
}

@Test
void testCountDistinct() {
String aql = "SELECT COUNT(DISTINCT d/ehr_id/value) FROM EHR d";
Expand Down

0 comments on commit 5ef1eca

Please sign in to comment.