Merge remote-tracking branch 'ebean/master' into pr/enh/post_process_find_controller

This commit is contained in:
Jonas Pöhler
2021-09-15 16:36:22 +02:00
19 changed files with 153 additions and 60 deletions
@@ -77,7 +77,7 @@ public class InPairsExpressionTest extends BaseExpressionTest {
public void diffSeparator_diff() throws Exception {
InPairsExpression e0 = new InPairsExpression(pairs(), false);
InPairsExpression e1 = new InPairsExpression(pairs().setConcatSeparator(":"), false);
InPairsExpression e1 = new InPairsExpression(pairs().concatSeparator(":"), false);
different(e0, e1);
}
@@ -85,7 +85,7 @@ public class InPairsExpressionTest extends BaseExpressionTest {
public void diffSuffix_diff() throws Exception {
InPairsExpression e0 = new InPairsExpression(pairs(), false);
InPairsExpression e1 = new InPairsExpression(pairs().setConcatSuffix(":"), false);
InPairsExpression e1 = new InPairsExpression(pairs().concatSuffix(":"), false);
different(e0, e1);
}
@@ -16,7 +16,10 @@ import java.util.List;
import java.util.function.Consumer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestQueryCache extends BaseTestCase {
@@ -126,15 +129,52 @@ public class TestQueryCache extends BaseTestCase {
// and now, ensure that we hit the database
LoggedSql.start();
int count2 = DB.find(EColAB.class)
.setUseQueryCache(CacheMode.OFF)
.where()
.eq("columnB", "count")
.findCount();
.setUseQueryCache(CacheMode.OFF)
.where()
.eq("columnB", "count")
.findCount();
assertThat(count2).isEqualTo(count1);
sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
}
@Test
public void exists() {
new EColAB("06", "exists").save();
new EColAB("07", "exists").save();
LoggedSql.start();
boolean exists0 = DB.find(EColAB.class)
.setUseQueryCache(CacheMode.ON)
.where()
.eq("columnB", "exists")
.exists();
boolean exists1 = DB.find(EColAB.class)
.setUseQueryCache(CacheMode.ON)
.where()
.eq("columnB", "exists")
.exists();
List<String> sql = LoggedSql.stop();
assertThat(exists0).isEqualTo(exists1);
assertThat(sql).hasSize(1);
// and now, ensure that we hit the database
LoggedSql.start();
boolean exists2 = DB.find(EColAB.class)
.setUseQueryCache(CacheMode.OFF)
.where()
.eq("columnB", "exists")
.exists();
assertThat(exists2).isEqualTo(exists1);
sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
}
@Test
public void findCountDifferentQueries() {
@@ -386,8 +386,8 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
loadSomeIntoCache();
Pairs pairs = new Pairs("sku", "code")
.setConcatSeparator(":")
.setConcatSuffix("-foo")
.concatSeparator(":")
.concatSuffix("-foo")
.add("2", 1000)
.add("2", 1001)
.add("3", 1000);