mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1870 - Whether DtoMeta.findproperty needs to add is prefix
This commit is contained in:
@@ -270,6 +270,24 @@ public class DtoQueryFromOrmTest extends BaseTestCase {
|
||||
assertThat(sql.get(0)).contains("select t0.last_name, count(*) totalCount from contact t0 where t0.last_name is not null group by t0.last_name having count(*) > ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDto_withIsBooleanProperty() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
DB.sqlUpdate("update contact set is_member=? where last_name like ?")
|
||||
.setParams(true, "B%")
|
||||
.execute();
|
||||
|
||||
final List<ContactMemberDto> contacts =
|
||||
DB.find(Contact.class).select("lastName, isMember")
|
||||
.where().eq("isMember", true)
|
||||
.asDto(ContactMemberDto.class)
|
||||
.findList();
|
||||
|
||||
assertThat(contacts).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDto_fromExpressionList() {
|
||||
|
||||
@@ -343,4 +361,26 @@ public class DtoQueryFromOrmTest extends BaseTestCase {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ContactMemberDto {
|
||||
|
||||
String lastName;
|
||||
boolean member;
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public boolean isMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void setMember(boolean member) {
|
||||
this.member = member;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ public class EqlParserTest extends BaseTestCase {
|
||||
Query<Customer> query = parse("select name fetch billingAddress (line1, city) fetch contacts");
|
||||
query.findList();
|
||||
|
||||
assertThat(sqlOf(query, 12)).contains("select t0.id, t0.name, t1.id, t1.line_1, t1.city, t2.id, t2.first_name, t2.last_name, t2.phone, t2.mobile, t2.email, t2.cretime, t2.updtime, t2.customer_id, t2.group_id from o_customer t0");
|
||||
assertThat(sqlOf(query, 12)).contains("select t0.id, t0.name, t1.id, t1.line_1, t1.city, t2.id, t2.first_name, t2.last_name, t2.phone, t2.mobile, t2.email, t2.is_member, t2.cretime, t2.updtime, t2.customer_id, t2.group_id from o_customer t0");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public class Contact {
|
||||
String mobile;
|
||||
String email;
|
||||
|
||||
boolean isMember;
|
||||
|
||||
@DocEmbedded(doc = "id,name")
|
||||
@ManyToOne(optional = false)
|
||||
Customer customer;
|
||||
@@ -129,6 +131,14 @@ public class Contact {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public boolean isMember() {
|
||||
return isMember;
|
||||
}
|
||||
|
||||
public void setMember(boolean member) {
|
||||
isMember = member;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user