Update tests only for Oracle

This commit is contained in:
Rob Bygrave committed 2021-09-23 18:49:28 +12:00
1 parent 35a6ff7f02
commit 9af006b15b
14 files changed
+51 -41

No files matched your search

@@ -28,7 +28,7 @@ public class ForTestsBeforeAfterTest extends BaseTestCase {
assertThat(getCount()).isEqualTo(0);
}
@IgnorePlatform(Platform.SQLSERVER)
@IgnorePlatform({Platform.SQLSERVER, Platform.ORACLE})
@Test
public void createRollbackAll() {
doInsert();
@@ -36,7 +36,7 @@ public class ForTestsTest extends BaseTestCase {
assertThat(transaction).isNull();
}
@IgnorePlatform(Platform.SQLSERVER)
@IgnorePlatform({Platform.SQLSERVER, Platform.ORACLE})
@Test
public void rollbackTransactions() {
@@ -4,6 +4,7 @@ import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.SqlRow;
import io.ebean.annotation.ForPlatform;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.DbEncrypt;
import io.ebean.test.LoggedSql;
@@ -55,6 +56,7 @@ public class TestEncrypt extends BaseTestCase {
assertThat(loggedSql.get(1)).contains("left join e_basicenc t1 on t1.id = t0.other_id");
}
@IgnorePlatform(Platform.ORACLE)
@Test
public void asDto() {
DB.find(EBasicEncrypt.class).delete();
@@ -24,26 +24,26 @@ public class TestM2MWithWhere extends BaseTestCase {
List<MnyNode> result = DB.find(MnyNode.class).where().eq("allRelations", node).findList();
assertThat(result).extracting(MnyNode::getId).containsExactly(1, 2, 3, 4, 5);
assertThat(result).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2, 3, 4, 5);
result = DB.find(MnyNode.class).where().eq("allReverseRelations", node).findList();
assertThat(result).extracting(MnyNode::getId).containsExactly(1, 2, 3, 4, 5);
assertThat(result).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2, 3, 4, 5);
result = DB.find(MnyNode.class).where().eq("bit1Relations", node).findList();
assertThat(result).isEmpty(); // -> to = 1 column: 2 0 2 0 2
result = DB.find(MnyNode.class).where().eq("bit2Relations", node).findList();
assertThat(result).extracting(MnyNode::getId).containsExactly(1, 3, 5);
assertThat(result).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 3, 5);
result = DB.find(MnyNode.class).where().eq("bit1ReverseRelations", node).findList();
// -> from = 1 column: 2 1 3 1 3
assertThat(result).extracting(MnyNode::getId).containsExactly(2, 3, 4, 5);
assertThat(result).extracting(MnyNode::getId).containsExactlyInAnyOrder(2, 3, 4, 5);
result = DB.find(MnyNode.class).where().eq("bit2ReverseRelations", node).findList();
assertThat(result).hasSize(3).extracting(MnyNode::getId).containsExactly(1, 3, 5);
assertThat(result).hasSize(3).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 3, 5);
result = DB.find(MnyNode.class).where().eq("bit2ReverseRelations", node).findList();
assertThat(result).hasSize(3).extracting(MnyNode::getId).containsExactly(1, 3, 5);
assertThat(result).hasSize(3).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 3, 5);
}
@Test
@@ -51,18 +51,18 @@ public class TestM2MWithWhere extends BaseTestCase {
createTestData();
MnyNode node = DB.find(MnyNode.class, 3);
assertThat(node.getAllRelations()).extracting(MnyNode::getId).containsExactly(1, 2, 3, 4, 5);
assertThat(node.getAllRelations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2, 3, 4, 5);
assertThat(node.getAllReverseRelations()).extracting(MnyNode::getId).containsExactly(1, 2, 3, 4, 5);
assertThat(node.getAllReverseRelations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2, 3, 4, 5);
assertThat(node.getBit1Relations()).extracting(MnyNode::getId).containsExactly(4, 5);
assertThat(node.getBit1Relations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(4, 5);
assertThat(node.getBit1ReverseRelations()).extracting(MnyNode::getId).containsExactly(1, 2);
assertThat(node.getBit1ReverseRelations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2);
assertThat(node.getBit2Relations()).extracting(MnyNode::getId).containsExactly(1, 3, 5);
assertThat(node.getBit2Relations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 3, 5);
LoggedSql.start();
assertThat(node.getBit2ReverseRelations()).extracting(MnyNode::getId).containsExactly(1, 3, 5);
assertThat(node.getBit2ReverseRelations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 3, 5);
List<String> sqls = LoggedSql.stop();
assertThat(sqls).hasSize(1); // lazy load
@@ -77,8 +77,8 @@ public class TestM2MWithWhere extends BaseTestCase {
// no lazyLoad expected
LoggedSql.start();
assertThat(node.getBit1Relations()).extracting(MnyNode::getId).containsExactly(4, 5);
assertThat(node.getBit1ReverseRelations()).extracting(MnyNode::getId).containsExactly(1, 2);
assertThat(node.getBit1Relations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(4, 5);
assertThat(node.getBit1ReverseRelations()).extracting(MnyNode::getId).containsExactlyInAnyOrder(1, 2);
sqls = LoggedSql.stop();
assertThat(sqls).hasSize(0);
@@ -148,7 +148,7 @@ public class TestM2MWithWhere extends BaseTestCase {
el.getWithDbTableName().size(); // trigger Lazy load
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(2);
assertThat(sql.get(0)).contains("select t0.id, t0.name from mny_node");
assertSql(sql.get(0)).contains("select t0.id, t0.name from mny_node");
assertThat(sql.get(1)).contains("where 'mny_node' = t0.name");
DB.delete(el);
}
@@ -35,7 +35,7 @@ public class TestOneToManyWhere extends BaseTestCase {
el.getChildrenWithWhere().size(); // trigger Lazy load
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(2);
assertThat(sql.get(0)).contains("select t0.id, t0.name from om_basic_parent");
assertSql(sql.get(0)).contains("select t0.id, t0.name from om_basic_parent");
assertThat(sql.get(1)).contains("where 'om_basic_parent' = t0.name");
DB.delete(el);
}
@@ -72,7 +72,7 @@ public class TestSubQuery extends BaseTestCase {
if (isPostgres()) {
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 {
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 in (?)");
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 (?)");
}
Query<Order> query = DB.find(Order.class).select("shipDate").where().isIn("id", sq).query();
@@ -81,7 +81,7 @@ public class TestSubQuery extends BaseTestCase {
if (isPostgres()) {
assertThat(query.getGeneratedSql()).isEqualTo("select t0.ship_date from o_order t0 where (t0.id) in (" + debugSq.getGeneratedSql() + ")");
} else {
assertThat(query.getGeneratedSql()).isEqualTo("select t0.ship_date from o_order t0 where (t0.id) in (" + debugSq.getGeneratedSql() + ")");
assertSql(query.getGeneratedSql()).isEqualTo("select t0.ship_date from o_order t0 where (t0.id) in (" + trimSql(debugSq.getGeneratedSql()) + ")");
}
}
@@ -101,8 +101,8 @@ public class TestSubQuery extends BaseTestCase {
Query<Order> query = DB.find(Order.class).select("status").where().isIn("shipDate", sq).query();
query.findSingleAttribute();
assertThat(query.getGeneratedSql())
.isEqualTo("select t0.status from o_order t0 where (t0.ship_date) in (" + debugSq.getGeneratedSql() + ")");
assertSql(query.getGeneratedSql())
.isEqualTo("select t0.status from o_order t0 where (t0.ship_date) in (" + trimSql(debugSq.getGeneratedSql()) + ")");
}
/**
@@ -120,13 +120,13 @@ public class TestSubQuery extends BaseTestCase {
// execute the subQuery as copy (generatedSQL must be part of original query)
Query<OrderDetail> debugSq = sq.copy();
debugSq.findSingleAttribute();
assertThat(debugSq.getGeneratedSql()).contains("select t2.id from o_order_detail t0 join o_order t1 on t1.id = t0.order_id left join or_order_ship t2");
assertSql(debugSq.getGeneratedSql()).contains("select t2.id from o_order_detail t0 join o_order t1 on t1.id = t0.order_id left join or_order_ship t2");
Query<OrderShipment> query = DB.find(OrderShipment.class).select("shipTime").where().isIn("id", sq).query();
query.findSingleAttribute();
assertThat(query.getGeneratedSql())
.isEqualTo("select t0.ship_time from or_order_ship t0 where (t0.id) in (" + debugSq.getGeneratedSql() + ")");
assertSql(query.getGeneratedSql())
.isEqualTo("select t0.ship_time from or_order_ship t0 where (t0.id) in (" + trimSql(debugSq.getGeneratedSql()) + ")");
}
public void testCompositeKey() {
@@ -81,7 +81,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
.order().asc("order.totalAmount");
shipQuery.findList();
assertThat(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
+ "from or_order_ship t0 "
+ "left join o_order t1 on t1.id = t0.order_id "
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
@@ -98,7 +98,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
.where().isNotNull("order.totalAmount").query();
shipQuery.findList();
assertThat(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id "
+ "from or_order_ship t0 "
+ "left join o_order t1 on t1.id = t0.order_id "
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
@@ -118,7 +118,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
if (isPostgres()) {
assertThat(shipQuery.getGeneratedSql()).contains("select distinct on (t0.id) t0.id from or_order_ship t0");
} else {
assertThat(shipQuery.getGeneratedSql()).contains("select distinct t0.id from or_order_ship t0 ");
assertSql(shipQuery.getGeneratedSql()).contains("select distinct t0.id from or_order_ship t0 ");
}
assertThat(shipQuery.getGeneratedSql()).contains(
"from or_order_ship t0 " +
@@ -139,7 +139,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
.order().asc("order.totalAmount");
shipQuery.findList();
assertThat(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
+ "from or_order_ship t0 "
+ "left join o_order t1 on t1.id = t0.order_id "
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
@@ -156,7 +156,7 @@ public class TestQueryJoinOnFormula extends BaseTestCase {
.where().isNotNull("order.totalAmount").query();
shipQuery.findList();
assertThat(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
assertSql(shipQuery.getGeneratedSql()).isEqualTo("select t0.id, t1.id, z_bt1.total_amount "
+ "from or_order_ship t0 "
+ "left join o_order t1 on t1.id = t0.order_id "
+ "left join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_bt1 on z_bt1.order_id = t1.id "
@@ -708,7 +708,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
.findSingleAttributeList();
if (isOracle()) {
assertSql(query).contains("select r1.attribute_, count(*) from (select t2.line_1 as attribute_ from contact t0 join o_customer t1 on t1.id = t0.customer_id left join o_address t2 on t2.id = t1.billing_address_id where t2.line_1 is not null) r1 group by r1.attribute_ order by r1.attribute_ desc offset 1 rows fetch next 2 rows only");
assertSql(query).contains("select r1.attribute_, count(*) from (select t2.line_1 as attribute_ from contact t0 join o_customer t1 on t1.id = t0.customer_id left join o_address t2 on t2.id = t1.billing_address_id where t2.line_1 is not null) r1 group by r1.attribute_ order by r1.attribute_ desc offset 1 rows fetch next 2 rows only");
} else {
assertSql(query).contains("select r1.attribute_, count(*) from ("
+ "select t2.line_1 as attribute_ from contact t0 "
@@ -236,7 +236,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
.query();
List<EBasicSoftDelete> list = query.findList();
if (isMySql() || isMariaDB() || isSqlServer()) {
if (isMySql() || isMariaDB() || isSqlServer() || isOracle()) {
assertSql(query).contains("t0.deleted = 0");
assertSql(query).contains("u1.deleted = 0");
} else {
@@ -272,7 +272,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
List<EBasicNoSDChild> list = query.findList();
// Make sure that query includes that the child mustn't've been deleted
if (isMySql() || isMariaDB() || isSqlServer()) {
if (isMySql() || isMariaDB() || isSqlServer() || isOracle()) {
assertSql(query).contains("u1.deleted = 0");
assertSql(query).contains("u2.deleted = 0");
} else {
@@ -59,7 +59,7 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase {
final List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
if (isSqlServer() || isMySql() || isMariaDB()) {
if (isSqlServer() || isMySql() || isMariaDB() || isOracle()) {
assertThat(sql.get(0)).contains("left join esoft_del_z t1 on t1.id = t0.organization_id and t1.deleted = 0 where");
} else {
assertThat(sql.get(0)).contains("left join esoft_del_z t1 on t1.id = t0.organization_id and t1.deleted = false where");
@@ -248,12 +248,12 @@ public class TestTransparentPersist extends BaseTestCase {
assertThat(checkOrder.getShipments().size()).isEqualTo(1);
assertThat(sql).hasSize(10);
assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.order_date");
assertSql(sql.get(0)).contains("select t0.id, t0.status, t0.order_date");
assertThat(sql.get(1)).contains("insert into o_customer");
assertThat(sql.get(2)).contains(" -- bind(");
assertThat(sql.get(3)).contains("update o_order set updtime=?, kcustomer_id=? where id=? and updtime=?");
assertThat(sql.get(4)).contains(" -- bind(");
assertThat(sql.get(5)).contains("select t0.order_id, t0.id, t0.ship_time, t0.cretime, t0.updtime, t0.version, t0.order_id from or_order_ship");
assertSql(sql.get(5)).contains("select t0.order_id, t0.id, t0.ship_time, t0.cretime, t0.updtime, t0.version, t0.order_id from or_order_ship");
assertThat(sql.get(6)).contains("delete from or_order_ship");
assertThat(sql.get(7)).contains(" -- bind(");
assertThat(sql.get(8)).contains("insert into or_order_ship");