mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 03:57:45 +00:00
#1572 - Support query.select("customer.id").findSingleAttributeList() ... in addition to the expected and working select("customer").findSingleAttributeList()
This commit is contained in:
@@ -419,15 +419,11 @@ public final class SqlTreeBuilder {
|
||||
} else {
|
||||
logger.error("property [" + propName + "] not found on " + desc + " for query - excluding it.");
|
||||
}
|
||||
|
||||
} else if (p.isEmbedded()) {
|
||||
// add the embedded bean (and effectively
|
||||
// all its properties)
|
||||
} else if (p.isEmbedded() || (p instanceof STreePropertyAssoc && !queryProps.isIncludedBeanJoin(p.getName()))) {
|
||||
// add the embedded bean or the *ToOne assoc bean. We skip the check that the *ToOne propName maps to Id property ...
|
||||
selectProps.add(p);
|
||||
|
||||
} else {
|
||||
String m = "property [" + p.getFullBeanName() + "] expected to be an embedded bean for query - excluding it.";
|
||||
logger.error(m);
|
||||
logger.error("property [" + p.getFullBeanName() + "] expected to be an embedded or *ToOne bean for query - excluding it.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -359,6 +359,21 @@ public class TestQuerySingleAttribute extends BaseTestCase {
|
||||
assertThat(sqlOf(query)).contains("select distinct t0.customer_id from contact t0 order by t0.customer_id desc");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void distinctWithOrderByPkWithId() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Contact> query = Ebean.find(Contact.class)
|
||||
.setDistinct(true)
|
||||
.select("customer.id")
|
||||
.orderBy().desc("customer.id");
|
||||
|
||||
query.findSingleAttributeList();
|
||||
|
||||
assertThat(sqlOf(query)).contains("select distinct t0.customer_id from contact t0 order by t0.customer_id desc");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void distinctWithCascadedFetchOrderByPk() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user