Unittest for select Query with (*,x(y))

This commit is contained in:
Noemi Szemenyei
2021-11-10 13:30:24 +01:00
parent 85ec1d3d84
commit abf311de93
@@ -1,8 +1,11 @@
package io.ebean.text;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.FetchPath;
import io.ebean.Query;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -14,7 +17,7 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class PathPropertiesTests {
public class PathPropertiesTests extends BaseTestCase {
private static final Logger log = LoggerFactory.getLogger(PathPropertiesTests.class);
@@ -212,4 +215,16 @@ public class PathPropertiesTests {
String asJson = DB.json().toJson(list, pathProps);
log.info("Json: {}", asJson);
}
@Test
public void test_withAllPropsQuery() {
PathProperties root = PathProperties.parse("*,billingAddress(line1)");
LoggedSql.start();
Query<Customer> query = DB.find(Customer.class).apply(root);
query.findList();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("select t0.status, t0.name, t0.smallnote, t0.anniversary, t0.id, t1.id, t1.line_1 from o_customer t0 left join o_address t1 on t1.id = t0.billing_address_id");
}
}