Skip to content

Support for Function Expressions in String Queries #643

@otaviojava

Description

@otaviojava

Jakarta Query supports a variety of built-in functions via its grammar:

function_expression
    : 'ABS' '(' scalar_expression ')'
    | 'LENGTH' '(' scalar_expression ')'
    | 'LOWER' '(' scalar_expression ')'
    | 'UPPER' '(' scalar_expression ')'
    | 'LEFT' '(' scalar_expression ',' scalar_expression ')'
    | 'RIGHT' '(' scalar_expression ',' scalar_expression ')'

These expressions are valid in WHERE clauses of string-based queries.

🎯 Goal

Enable support in Eclipse JNoSQL for the above function_expression types when using Jakarta Query integration.

🔍 Examples

Support should include queries such as:

SELECT * FROM Customer WHERE LENGTH(name) > 5
SELECT * FROM Product WHERE LOWER(category) = 'electronics'
SELECT * FROM Book WHERE ABS(price) > 10
SELECT * FROM Name WHERE LEFT(name, 2) = 'Jo'
SELECT * FROM Name WHERE RIGHT(name, 1) = 'y'

✅ With Parameters

Queries with parameters must also be supported:

SELECT * FROM Customer WHERE LENGTH(:name) > :minLength
SELECT * FROM Product WHERE LOWER(:category) = 'electronics'
SELECT * FROM Customer WHERE LEFT(:name, :quantity) = 'Jo'

Java example:

template.query("SELECT * FROM Customer WHERE LEFT(:name, :len) = 'Jo'", Customer.class)
        .bind("name", "Johnathan")
        .bind("len", 2)
        .result();

✅ Tasks

  • Enhance the Jakarta Query parser integration in Eclipse JNoSQL to support the above function_expression types.
  • Ensure parameters (e.g., :name, :len) can be bound in function expressions.
  • Add tests for each supported function (with and without parameters).
  • Document usage examples in JNoSQL reference guides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions