mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
fix several bugs in findSingleAttibute (#980)
* add test case for distinct on id property * suggested fix for "select distinct id" * add test case for distinct with fetch * FIX: .setDistinct(true) can be used in conjunction with fetch() now * add test case for distinct with beans that have a disriminator column * FIX: discriminator column is only read if also Id is read. * fine tuned the test case * added test cases for findSingleAttributeList without distinct * improved fix to support also findSingleAttribute without distinct * ADD: Bonus test case - assertion not yet verified
This commit is contained in:
committed by
Rob Bygrave
parent
40ca179509
commit
a46e086dc4
@@ -322,7 +322,9 @@ public class SqlTreeBuilder {
|
||||
return new SqlTreeNodeManyRoot(prefix, (BeanPropertyAssocMany<?>) prop, props, myList, temporalMode, disableLazyLoad);
|
||||
|
||||
} else {
|
||||
return new SqlTreeNodeBean(prefix, prop, props, myList, temporalMode, disableLazyLoad);
|
||||
// do not read Id on child beans (e.g. when used with fetch())
|
||||
boolean withId = (query == null || !query.isSingleAttribute());
|
||||
return new SqlTreeNodeBean(prefix, prop, props, myList, withId, temporalMode, disableLazyLoad);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +440,7 @@ public class SqlTreeBuilder {
|
||||
p = desc.findBeanProperty("id");
|
||||
selectProps.add(p);
|
||||
|
||||
} else if (p.isId()) {
|
||||
} else if (p.isId() && (query == null || !query.isSingleAttribute())) {
|
||||
// do not bother to include id for normal queries as the
|
||||
// id is always added (except for subQueries)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user