mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Pr/add tests (#1103)
* ADD: Testcase for Sqlserver-6.2.0 driver * CHG: Removed Row-limit - so we need no special handling when sqlserver-platform generates a "select top 100" statement * ADD: additional asserts to TestQueryCache * CHG: Ignore test for sqlserver
This commit is contained in:
committed by
Rob Bygrave
parent
96e3f4138f
commit
e908d16ba8
@@ -83,6 +83,17 @@ public class TestQueryCache extends BaseTestCase {
|
||||
.findSingleAttributeList();
|
||||
|
||||
assertThat(colA_Second).isNotSameAs(colA_NotDistinct);
|
||||
|
||||
// ensure that findCount & findSingleAttribute use different
|
||||
// slots in cache. If not a "Cannot cast List to int" should happen.
|
||||
int count = Ebean.getServer(null)
|
||||
.find(EColAB.class)
|
||||
.setUseQueryCache(true)
|
||||
.select("columnA")
|
||||
.where()
|
||||
.eq("columnB", "SingleAttribute")
|
||||
.findCount();
|
||||
assertThat(count).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,8 +120,43 @@ public class TestQueryCache extends BaseTestCase {
|
||||
|
||||
assertThat(count0).isEqualTo(count1);
|
||||
assertThat(sql).hasSize(1);
|
||||
|
||||
// and now, ensure that we hit the database
|
||||
LoggedSqlCollector.start();
|
||||
int count2 = Ebean.find(EColAB.class)
|
||||
.setUseQueryCache(false)
|
||||
.where()
|
||||
.eq("columnB", "count")
|
||||
.findCount();
|
||||
assertThat(count2).isEqualTo(count1);
|
||||
sql = LoggedSqlCollector.stop();
|
||||
assertThat(sql).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findCountDifferentQueries() {
|
||||
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
int count0 = Ebean.find(EColAB.class)
|
||||
.setUseQueryCache(true)
|
||||
.where()
|
||||
.eq("columnB", "abc")
|
||||
.findCount();
|
||||
|
||||
int count1 = Ebean.find(EColAB.class)
|
||||
.setUseQueryCache(true)
|
||||
.where()
|
||||
.eq("columnB", "def")
|
||||
.findCount();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
assertThat(count0).isEqualTo(count1);
|
||||
assertThat(sql).hasSize(2); // different queries
|
||||
|
||||
}
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test() {
|
||||
|
||||
Reference in New Issue
Block a user