New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QueryBuilder.limit() should not be used with findShadowsAndStream() - as it's misleading #822
Comments
@bartoszwalacik seems like this is a documented behavior, org.javers.core.Javers#findShadowsAndStream, and limit is used as a fetch size and not as an actual limit, i would propose to restrict using limit this way, just like .skip(), as its confusing and add a reasonable fetch size by default and mb a property or a param in query builder for customization |
true, there is no bug, limit() works as it shoud and as documented.
class ShadowStreamLimitBug extends Specification {
def "should find shadows and stream with limit" () {
given:
Javers javers = JaversBuilder.javers().build()
Employee frodo = new Employee("Frodo")
frodo.addSubordinate(new Employee("Sam"))
javers.commit("author", frodo)
when:
(1..10).forEach( i -> {
frodo.setSalary(1_000 * i)
javers.commit("author", frodo)
})
Stream<Shadow<Employee>> shadows = javers.findShadowsAndStream(
QueryBuilder.byInstanceId("Frodo", Employee.class).limit(2).build())
then:
shadows.count() == 11
}
} |
confusing in terms of naming when we use limit as not a limit, but as a fetch size for paging. |
Agreed, but this confusion is not easy to solve. For all find*() methods except findShadowsAndStream - limit() means the real limit :) |
suggestion is the same - restrict using limit for stream method, just like its done for .skip - |
new semantic of limit() in Shadow queries (both List ans Stream) Paging & limit Returned list of Shadow graphs is always complete (according to the selected |
fixed in 6.0.0-rc1 see https://javers.org/documentation/jql-examples/#limit-filter |
When using the findShadowsAndStream method and making a query with limit set to a number smaller then the actual object's shadows then the method returns incorrect number of shadows.
See test case
The text was updated successfully, but these errors were encountered: