#2876 & #2875 - Query Beans subquery exists/notExists + eq(other property), ne(other property)

This commit is contained in:
Rob Bygrave committed 2022-11-02 16:14:44 +13:00
1 parent b300db77ff
commit f6b87ed0b4
4 files changed
+120

No files matched your search

@@ -155,6 +155,39 @@ public class QCustomerTest {
}
}
@Test
void equalTo_byProperty() {
Query<Customer> query = new QCustomer()
.select(QCustomer.Alias.id)
.billingAddress.city.eq(QCustomer.Alias.shippingAddress.city)
.query();
query.findList();
String generatedSql = query.getGeneratedSql();
// select t0.id from be_customer t0
// left join o_address t2 on t2.id = t0.shipping_address_id
// left join o_address t1 on t1.id = t0.billing_address_id
// where t1.city = t2.city
assertThat(generatedSql).contains("where t1.city = t2.city");
}
@Test
void notEqual_byProperty() {
Query<Customer> query = new QCustomer()
.select(QCustomer.Alias.id)
.billingAddress.city.ne(QCustomer.Alias.shippingAddress.city)
.query();
query.findList();
String generatedSql = query.getGeneratedSql();
// select t0.id from be_customer t0
// left join o_address t2 on t2.id = t0.shipping_address_id
// left join o_address t1 on t1.id = t0.billing_address_id
// where t1.city <> t2.city
assertThat(generatedSql).contains("where t1.city <> t2.city");
}
@Test
public void isEmpty() {