Skip to content
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

Invalid query when ORDER BY with DISTINCT #85

Closed
Ryszard-Trojnacki opened this issue Apr 7, 2014 · 2 comments
Closed

Invalid query when ORDER BY with DISTINCT #85

Ryszard-Trojnacki opened this issue Apr 7, 2014 · 2 comments
Labels

Comments

@Ryszard-Trojnacki
Copy link
Contributor

When I create Qurey with "order by" for example:

@Test
public void orderByWithoutLimit() {
db.createQuery(QueueJob.class).setDistinct(true).orderBy(QueueJob.USER+"."+User.USERNAME).findList();
}

which gives SQL Query something like this:
select distinct t0.id as c0, t0.file_id as c1, t0.file_name as c2, t0.driver_id as c3, t0.file_hash as c4, t0.user_id as c5, t0.job_id as c6 from queue_jobs t0 left outer join users t1 on t1.id = t0.user_id order by t1.username
limit 11

I got error from database (PosgreSQL, H2, Microsoft SQL Server; there is no error in mySQL) that "order by" property must be in select list:

ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

I think that in such cases the order by field should be added to select columns list.

@rbygrave
Copy link
Member

rbygrave commented Apr 7, 2014

Thanks. I'll ponder this for a little while (busy getting version 4 out) and then have another look.

@rbygrave rbygrave modified the milestones: 4.0.1, 5.0.1 Apr 30, 2014
@rbygrave rbygrave modified the milestones: 4.0.1, 5.0.1 May 18, 2014
@rbygrave
Copy link
Member

Fixed in 4.0.1

@rbygrave rbygrave added the bug label May 18, 2014
rbygrave pushed a commit that referenced this issue Mar 17, 2023
* FIX: DB.json().toBean(target) can update existing lists

* remove sys.print, typo

---------

Co-authored-by: Roland Praml <[email protected]>
Co-authored-by: Juri Skrobko <[email protected]>
rbygrave added a commit that referenced this issue Mar 17, 2023
FIX: DB.json().toBean(target) can update existing lists (#85)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants