Remove support for "query hints" like +query(50) (#2163)

* Remove support for "query hints" like +query(50)

* Remove unused readOnly from OrmQueryProperties

* OrmQueryProperties cache as final field
This commit is contained in:
Rob Bygrave
2021-02-14 11:21:10 +13:00
committed by GitHub
parent 4c16b85e85
commit a6fdc42934
6 changed files with 23 additions and 169 deletions
@@ -624,7 +624,7 @@ public class EqlParserTest extends BaseTestCase {
public void fetch_query50_asHint() {
ResetBasicData.reset();
Query<Customer> query = parse("fetch billingAddress (+query(50),city)");
Query<Customer> query = parse("fetch query(50) billingAddress (city)");
query.findList();
assertSql(query).doesNotContain(", t1.city");
@@ -634,7 +634,7 @@ public class EqlParserTest extends BaseTestCase {
public void fetch_lazy50_asHint() {
ResetBasicData.reset();
Query<Customer> query = parse("fetch billingAddress (+lazy(50),city) order by id");
Query<Customer> query = parse("fetch lazy(50) billingAddress (city) order by id");
List<Customer> list = query.findList();
assertSql(query).doesNotContain(", t1.city");
@@ -31,91 +31,17 @@ public class OrmQueryPropertiesParserTest {
}
@Test
public void when_hasCache() {
public void when_no_spaces() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache");
assertThat(res.cache).isTrue();
assertThat(res.included).isNull();
}
@Test
public void when_hasCache_first() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+cache,id");
assertThat(res.cache).isTrue();
assertThat(res.included).containsExactly("id");
}
@Test
public void when_hasCache_last() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache");
assertThat(res.cache).isTrue();
assertThat(res.included).containsExactly("name");
}
@Test
public void when_hasCache_middle() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+cache, id");
assertThat(res.cache).isTrue();
assertThat(res.included).containsExactly("name", "id");
}
@Test
public void when_hasReadOnly() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+readonly");
assertThat(res.readOnly).isTrue();
assertThat(res.included).isNull();
}
@Test
public void when_hasLazy() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy");
//FIXME: assertThat(res.fetchConfig.getBatchSize()).isEqualTo(0);
assertThat(res.included).isNull();
}
@Test
public void when_hasLazyValue() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20)");
assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20);
assertThat(res.included).isNull();
}
@Test
public void when_hasLazyValue_last() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("name,+lazy(20)");
assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20);
assertThat(res.included).containsExactly("name");
}
@Test
public void when_hasLazyValue_first() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+lazy(20),id,name");
assertThat(res.fetchConfig.getBatchSize()).isEqualTo(20);
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id,name");
assertThat(res.included).containsExactly("id", "name");
}
@Test
public void when_allProperties() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("+query(4),+lazy(5)");
assertThat(res.fetchConfig.getBatchSize()).isEqualTo(4);
assertThat(res.included).isNull();
}
public void when_spaced() {
@Test
public void when_everything_set() {
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name, +readonly ,+lazy(20), +query(30) ,+cache");
OrmQueryPropertiesParser.Response res = OrmQueryPropertiesParser.parse("id, name");
assertThat(res.included).containsExactly("id", "name");
assertThat(res.fetchConfig.getBatchSize()).isEqualTo(30);
assertThat(res.readOnly).isTrue();
assertThat(res.cache).isTrue();
}
@Test
@@ -126,8 +52,6 @@ public class OrmQueryPropertiesParserTest {
}
private void assertAllDefaults(OrmQueryPropertiesParser.Response res) {
assertThat(res.cache).isFalse();
assertThat(res.readOnly).isFalse();
assertThat(res.included).isNull();
}
}
@@ -21,7 +21,7 @@ public class TestLazyJoin extends BaseTestCase {
Query<Order> query = Ebean.find(Order.class)
.select("status")
.fetch("customer", "+lazy(10) name, status")
.fetchLazy("customer", "name, status")
.fetch("customer.contacts")
.order().asc("id");
@@ -28,7 +28,7 @@ public class TestQueryJoin extends BaseTestCase {
Query<Order> query = Ebean.find(Order.class).select("status")
// .join("details","+query(10)")
.fetch("customer", "+lazy(10), name, status").fetch("customer.contacts").order().asc("id");
.fetchLazy("customer", "name, status").fetch("customer.contacts").order().asc("id");
// .join("customer.billingAddress");
List<Order> list = query.findList();