Skip to content

Commit

Permalink
Fix orderby handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Apr 17, 2016
1 parent c1d1638 commit 7c81fd0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private <T> Path<T> convertPathForOrder(Path<T> path) {
if (metadata.getParent() != null && !metadata.getParent().getMetadata().isRoot()) {
Set<Expression<?>> exprs = Sets.newHashSet();
QueryMetadata md = getMetadata();
exprs.addAll(md.getProjection());
exprs.addAll(md.getGroupBy());
if (md.getWhere() != null) exprs.add(md.getWhere());
if (md.getHaving() != null) exprs.add(md.getHaving());
Expand Down
20 changes: 20 additions & 0 deletions querydsl-jpa/src/test/java/com/mysema/query/AbstractJPATest.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,26 @@ public void DistinctResults() {
assertEquals(1, query().from(cat).distinct().list(cat.birthdate).size());
}

@Test
public void Distinct_OrderBy() {
QCat cat = QCat.cat;
assertEquals(6, query()
.distinct()
.from(cat)
.orderBy(cat.mate.id.asc())
.list(cat.id, cat.mate.id).size());
}

@Test
public void Distinct_OrderBy2() {
QCat cat = QCat.cat;
assertEquals(4, query()
.distinct()
.from(cat)
.orderBy(cat.mate.id.asc())
.list(cat.id, cat.mate.id).size());
}

@Test
public void Date() {
query().from(cat).list(cat.birthdate.year());
Expand Down

0 comments on commit 7c81fd0

Please sign in to comment.