mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
Modify tests to use isPostgresCompatible() (to effectively include Yugabyte)
This commit is contained in:
1 parent
4899f23773
commit
389f2bcd2f
25 files changed
+37
-49
No files matched your search
@@ -29,7 +29,7 @@ public class TestQueryExists extends BaseTestCase {
|
||||
String sql = LoggedSql.stop().get(0);
|
||||
assertThat(check).isTrue();
|
||||
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sql).contains("select t0.id from o_order t0 where t0.id > ? limit 1");
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
assertThat(sqlList.get(0)).contains("lower(t0.name) = ?");
|
||||
assertThat(sqlList.get(1)).contains("status = ?");
|
||||
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).doesNotContain("offset");
|
||||
assertThat(sqlList.get(0)).contains(" limit 5");
|
||||
assertThat(sqlList.get(1)).contains(" offset 3");
|
||||
@@ -97,7 +97,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
assertThat(sqlList.get(0)).contains("lower(t0.name) = ?");
|
||||
assertThat(sqlList.get(1)).contains("status = ?");
|
||||
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).doesNotContain("offset");
|
||||
assertThat(sqlList.get(0)).contains(" limit 5");
|
||||
assertThat(sqlList.get(1)).contains(" offset 3");
|
||||
@@ -126,7 +126,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
assertThat(sqlList.get(0)).contains("lower(t0.name) = ?");
|
||||
assertThat(sqlList.get(1)).contains("status = ?");
|
||||
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).doesNotContain("offset");
|
||||
assertThat(sqlList.get(0)).contains(" limit 5");
|
||||
assertThat(sqlList.get(1)).contains(" order by t0.order_date desc, t0.id limit 100 offset 3");
|
||||
@@ -220,7 +220,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
List<String> sqlList = LoggedSql.stop();
|
||||
assertEquals(1, sqlList.size());
|
||||
assertThat(sqlList.get(0)).contains("from o_customer t0 left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null left join o_customer t2 on t2.id = t1.kcustomer_id where t1.status ");
|
||||
if (isPostgres()) {
|
||||
if (isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).contains("where t1.status = any(?) order by t0.id");
|
||||
} else {
|
||||
assertThat(sqlList.get(0)).contains("where t1.status in (?) order by t0.id");
|
||||
@@ -243,7 +243,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
List<String> sqlList = LoggedSql.stop();
|
||||
assertEquals(2, sqlList.size());
|
||||
assertThat(sqlList.get(0)).contains("from o_customer t0");
|
||||
if (isPostgres()) {
|
||||
if (isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(1)).contains("from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id where t0.order_date is not null and (t0.kcustomer_id) = any(?)");
|
||||
assertThat(sqlList.get(1)).contains(" and t0.status = any(?)");
|
||||
} else {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class TestSubQuery extends BaseTestCase {
|
||||
// execute the subQuery as copy (generatedSQL must be part of original query)
|
||||
Query<OrderDetail> debugSq = sq.copy();
|
||||
debugSq.findSingleAttribute();
|
||||
if (isPostgres()) {
|
||||
if (isPostgresCompatible()) {
|
||||
assertThat(debugSq.getGeneratedSql()).isEqualTo("select t1.id from o_order_detail t0 join o_order t1 on t1.id = t0.order_id where t0.product_id = any(?)");
|
||||
} else {
|
||||
assertSql(debugSq.getGeneratedSql()).isEqualTo("select t1.id from o_order_detail t0 join o_order t1 on t1.id = t0.order_id where t0.product_id in (?)");
|
||||
@@ -78,7 +78,7 @@ public class TestSubQuery extends BaseTestCase {
|
||||
Query<Order> query = DB.find(Order.class).select("shipDate").where().isIn("id", sq).query();
|
||||
query.findSingleAttribute();
|
||||
|
||||
if (isPostgres()) {
|
||||
if (isPostgresCompatible()) {
|
||||
assertThat(query.getGeneratedSql()).isEqualTo("select t0.ship_date from o_order t0 where (t0.id) in (" + debugSq.getGeneratedSql() + ")");
|
||||
} else {
|
||||
assertSql(query.getGeneratedSql()).isEqualTo("select t0.ship_date from o_order t0 where (t0.id) in (" + trimSql(debugSq.getGeneratedSql()) + ")");
|
||||
|
||||
@@ -149,7 +149,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
String sql = sqlOf(query, 5);
|
||||
if (isH2()) {
|
||||
assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount), sum(u1.my_units), t0.name from tevent_one t0 ");
|
||||
} else if (isPostgres()) {
|
||||
} else if (isPostgresCompatible()) {
|
||||
assertThat(sql).contains("t0.name, count(u1.id), sum(u1.my_units), sum(u1.my_units * u1.amount), sum(u1.my_units), t0.name from tevent_one t0 ");
|
||||
}
|
||||
assertThat(sql).contains("from tevent_one t0 join tevent_many u1 on u1.event_id = t0.id ");
|
||||
|
||||
@@ -237,7 +237,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
||||
assertThat(metricsJson).contains("\"name\":\"txn.main\"");
|
||||
assertThat(metricsJson).contains("\"name\":\"orm.Customer.findList\"");
|
||||
assertThat(metricsJson).contains("\"loc\":\"org.tests.model.basic.finder.CustomerFinder.byNameStatus\"");
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(metricsJson).contains("\"hash\":\"de3affa5b4bff07e19c1c012590dcde6\"");
|
||||
assertThat(metricsJson).contains("\"sql\":\"select t0.id, t0.status,");
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TestQueryDistinct extends BaseTestCase {
|
||||
|
||||
query.findList();
|
||||
|
||||
if (isH2() || isPostgres()) {
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
String generatedSql = sqlOf(query);
|
||||
assertThat(generatedSql).contains("select distinct t0.name from o_customer t0 limit 10");
|
||||
}
|
||||
|
||||
@@ -313,8 +313,7 @@ public class SqlQueryTests extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void firstRow() {
|
||||
|
||||
if (isPostgres()) {
|
||||
if (isPostgresCompatible()) {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
Reference in new issue
Block a user