Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

limit in FetchableFluentQueryBySpecification addes duplicate order by clause #3600

Closed
JingBh opened this issue Aug 29, 2024 · 1 comment · Fixed by #3601
Closed

limit in FetchableFluentQueryBySpecification addes duplicate order by clause #3600

JingBh opened this issue Aug 29, 2024 · 1 comment · Fixed by #3601
Assignees
Labels
type: bug A general bug

Comments

@JingBh
Copy link
Contributor

JingBh commented Aug 29, 2024

As this code in FetchableFluentQueryBySpecification shows, adding a limit applies the current sorting again.

@Override
public FetchableFluentQuery<R> limit(int limit) {
Assert.isTrue(limit >= 0, "Limit must not be negative");
return new FetchableFluentQueryBySpecification<>(spec, entityType, resultType, this.sort.and(sort), limit,
properties, finder, scroll, countOperation, existsOperation, entityManager, projectionFactory);
}

In my application, this is causing duplicate order by clause to be included in the SQL generated like order by q1_0."id" desc,q1_0."id" desc, as I call .sortBy first, and then .limit.

Of course, it's easy to fix on the application's side by calling .limit first, but I think this is a bug in the framework, as the other class FetchableFluentQueryByPredicate implementing the same interface does not have this behavior.

@quaff
Copy link
Contributor

quaff commented Aug 30, 2024

Good catch, I think it's better to force using this reference if same name of field and local variable present.

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 30, 2024
mp911de pushed a commit that referenced this issue Sep 2, 2024
mp911de pushed a commit that referenced this issue Sep 2, 2024
mp911de pushed a commit that referenced this issue Sep 2, 2024
@mp911de mp911de self-assigned this Sep 2, 2024
@mp911de mp911de added this to the 3.2.10 (2023.1.10) milestone Sep 3, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants