Cannot convert a String to Decimal128 in @Query usgin Spel

111 views Asked by At

I'm trying to do a convertion from String to Decimal128 in a @Query to perform a paging operation using the following snippet:

public interface ExpenseCollectionRepository extends ReactiveMongoRepository<ExpenseCollection, String> {

    Mono<Boolean> existsByDescriptionAndDueDate(String description, LocalDate dueDate);

    @Query("{'$or':" +
                " [" +
                    "{'description': '?0'}," +
                    "{'value': '?#{#search.matches(\"-?\\\\d+(\\\\.\\\\d+)?\") ? T(org.bson.types.Decimal128).parse(#search) : T(org.bson.types.Decimal128).parse(\"0.0\")}}'}," +
                    "{'paymentDate': '?0'}," +
                    "{'dueDate': '?0'}," +
                    "{'type': '?0'}," +
                    "{'payed': '?0'}" +
                "]" +
            "}")
    Flux<ExpenseCollection> findPage(@Param("search") String search, Pageable pageable);
}

What an I missing? Do I using Spel wrongly?

Github: https://github.com/SergioLuigi/expense-control/blob/bug/stack-over-flow-question/src/main/java/br/com/sergioluigi/expensecontroljava/expense/infrastructure/database/repository/ExpenseCollectionRepository.java

0

There are 0 answers