eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Other
231 stars 72 forks source link

[BUG] Using skip with DocumentTemplate does not have any effect #550

Closed m4ttek closed 2 months ago

m4ttek commented 2 months ago

Which JNoSQL project the issue refers to?

JNoSQL (Core)

Bug description

There is no possiblity to paginate records using SelectQueryBuilder and DocumentTemplate, specifically ArangoDBTemplate. PageRequest is also being ignored in queries.

Skip parameter is ignored and so I cannot paginate results with it.

JNoSQL Version

1.1.1

Steps To Reproduce

Build an example SelectQuery with skip and limit parameters set and try to invoke it on a DocumentTemplate object.

Expected Results

Records returned by select query should be properly paginated.

Code example, screenshot, or link to a repository

        return arangoDBTemplate.selectCursor(buildSelectQuery(filterCriteria)
                .sort(order.sorts().toArray(Sort[]::new))
                .skip((pageRequest.page() - 1) * pageRequest.size()) // it doesn't work
                .limit(pageRequest.size())
                .build(), pageRequest);
otaviojava commented 2 months ago

Thanks @m4ttek I am working on it.

otaviojava commented 2 months ago

Hey @m4ttek I've created the DRAFT PR, but I could not generate the issue:

https://github.com/eclipse/jnosql-databases/pull/283

Where did you get the selectCursor method?

m4ttek commented 2 months ago

@otaviojava it is the last method in SemiStructuredTemplate interface - it takes a PageRequest object as second parameter. Hence it shouldn't be necessary to invoke skip or limit - but it doesn't work neither.

otaviojava commented 2 months ago

@m4ttek, it is a documentation issue.

I've created the offset for this type of query; however, it will overwrite the SelectQuery in both cases based on the PageRequest.

If you don't want you can use the <T> Stream<T> select(SelectQuery query);

Once again, thank you for finding the bug.

m4ttek commented 2 months ago

@otaviojava great, thanks for info. If you release a new version, I'll check it :)

otaviojava commented 2 months ago

@m4ttek deploy as SNAPSHOT, could you try it?

We are working on finishing the TCK of Jakarta Data; as soon we finish, we will release a new version.

m4ttek commented 2 months ago

@otaviojava it seems to be working now :)

otaviojava commented 2 months ago

@m4ttek thanks for the feedback