mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Merge pull request #2548 from ebean-orm/feature/tests-for-cockroach
CockroachDB - Modify tests, use BigDecimal over Double etc
This commit is contained in:
@@ -297,7 +297,7 @@ public abstract class BaseTestCase {
|
||||
* Platform specific NOT IN clause assert.
|
||||
*/
|
||||
protected void platformAssertNotIn(String sql, String containsIn) {
|
||||
if (isPostgres() || isYugabyte()) {
|
||||
if (isPostgresCompatible()) {
|
||||
assertThat(sql).contains(containsIn+" != all(");
|
||||
} else {
|
||||
assertThat(sql).contains(containsIn+" not in ");
|
||||
|
||||
@@ -15,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class TestAggregateFormula extends BaseTestCase {
|
||||
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB, Platform.NUODB})
|
||||
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB, Platform.NUODB, Platform.COCKROACH})
|
||||
@Test
|
||||
public void minDistinctOrderByNulls() {
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TestJsonMapBasic extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(Platform.POSTGRES)
|
||||
@ForPlatform({Platform.POSTGRES, Platform.COCKROACH})
|
||||
public void whereManyPredicatePg() {
|
||||
|
||||
bean.setName("own1");
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.ebean.annotation.DocEmbedded;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ public class OrderDetail implements Serializable {
|
||||
|
||||
Integer shipQty;
|
||||
|
||||
Double unitPrice;
|
||||
BigDecimal unitPrice;
|
||||
|
||||
@ManyToOne
|
||||
@DocEmbedded(doc = "id,name,sku")
|
||||
@@ -41,7 +42,7 @@ public class OrderDetail implements Serializable {
|
||||
public OrderDetail() {
|
||||
}
|
||||
|
||||
public OrderDetail(Product product, Integer orderQty, Double unitPrice) {
|
||||
public OrderDetail(Product product, Integer orderQty, BigDecimal unitPrice) {
|
||||
this.product = product;
|
||||
this.orderQty = orderQty;
|
||||
this.unitPrice = unitPrice;
|
||||
@@ -89,11 +90,11 @@ public class OrderDetail implements Serializable {
|
||||
this.shipQty = shipQty;
|
||||
}
|
||||
|
||||
public Double getUnitPrice() {
|
||||
public BigDecimal getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Double unitPrice) {
|
||||
public void setUnitPrice(BigDecimal unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.ebean.Database;
|
||||
import io.ebean.Transaction;
|
||||
import org.tests.model.basic.Order.Status;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -213,9 +214,9 @@ public class ResetBasicData {
|
||||
order.setOrderDate(Date.valueOf("2018-07-01"));
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 5, 10.50));
|
||||
details.add(new OrderDetail(product2, 3, 1.10));
|
||||
details.add(new OrderDetail(product3, 1, 2.00));
|
||||
details.add(new OrderDetail(product1, 5, BigDecimal.valueOf(10.50)));
|
||||
details.add(new OrderDetail(product2, 3, BigDecimal.valueOf(1.10)));
|
||||
details.add(new OrderDetail(product3, 1, BigDecimal.valueOf(2.00)));
|
||||
order.setDetails(details);
|
||||
order.addShipment(new OrderShipment());
|
||||
DB.save(order);
|
||||
@@ -231,7 +232,7 @@ public class ResetBasicData {
|
||||
order.setOrderDate(Date.valueOf("2018-06-01"));
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 4, 10.50));
|
||||
details.add(new OrderDetail(product1, 4, BigDecimal.valueOf(10.50)));
|
||||
order.setDetails(details);
|
||||
order.addShipment(new OrderShipment());
|
||||
DB.save(order);
|
||||
@@ -247,9 +248,9 @@ public class ResetBasicData {
|
||||
order.setOrderDate(Date.valueOf("2018-07-02"));
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 3, 10.50));
|
||||
details.add(new OrderDetail(product3, 40, 2.10));
|
||||
details.add(new OrderDetail(product1, 5, 10.00));
|
||||
details.add(new OrderDetail(product1, 3, BigDecimal.valueOf(10.50)));
|
||||
details.add(new OrderDetail(product3, 40, BigDecimal.valueOf(2.10)));
|
||||
details.add(new OrderDetail(product1, 5, BigDecimal.valueOf(10.00)));
|
||||
order.setDetails(details);
|
||||
order.addShipment(new OrderShipment());
|
||||
DB.save(order);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class TestHistoryExclude extends BaseTestCase {
|
||||
linkFound.getDocs().size();
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||
@Test
|
||||
public void testAsOfThenLazy() {
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TestHistoryInclude extends BaseTestCase {
|
||||
assertThat(linkFound.getDocs().size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||
@Test
|
||||
public void testAsOfThenLazy() {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestHistoryOneToMany extends BaseTestCase {
|
||||
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||
@Test
|
||||
public void test() throws InterruptedException {
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.tests.model.tevent;
|
||||
import io.ebean.annotation.Aggregation;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@@ -33,10 +34,10 @@ public class TEventOne {
|
||||
Long count;
|
||||
|
||||
@Aggregation("sum(logs.myUnits)")
|
||||
Double totalUnits;
|
||||
BigDecimal totalUnits;
|
||||
|
||||
@Aggregation("sum(logs.myUnits * logs.amount)")
|
||||
Double totalAmount;
|
||||
BigDecimal totalAmount;
|
||||
|
||||
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
|
||||
List<TEventMany> logs;
|
||||
@@ -63,11 +64,11 @@ public class TEventOne {
|
||||
return count;
|
||||
}
|
||||
|
||||
public Double getTotalUnits() {
|
||||
public BigDecimal getTotalUnits() {
|
||||
return totalUnits;
|
||||
}
|
||||
|
||||
public Double getTotalAmount() {
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.tests.model.basic.ResetBasicData;
|
||||
import org.tests.model.tevent.TEventMany;
|
||||
import org.tests.model.tevent.TEventOne;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
@@ -53,7 +54,7 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
for (TEventOne eventOne : list) {
|
||||
// lazy loading on Aggregation properties
|
||||
// is not expected to work at this stage
|
||||
Double totalAmount = eventOne.getTotalAmount();
|
||||
BigDecimal totalAmount = eventOne.getTotalAmount();
|
||||
assertThat(totalAmount).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.tests.model.basic.*;
|
||||
import org.tests.model.basic.Order.Status;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@@ -36,14 +37,14 @@ public class TestTextJsonUpdateCascade extends TransactionalTestCase {
|
||||
|
||||
OrderDetail orderDetail0 = order.getDetails().get(0);
|
||||
orderDetail0.setShipQty(300);
|
||||
orderDetail0.setUnitPrice(56.98d);
|
||||
orderDetail0.setUnitPrice(BigDecimal.valueOf(56.98d));
|
||||
|
||||
// remove one of the details...
|
||||
OrderDetail removedDetail = order.getDetails().remove(2);
|
||||
assertNotNull(removedDetail);
|
||||
|
||||
Product p = DB.reference(Product.class, 1);
|
||||
OrderDetail newDetail = new OrderDetail(p, 899, 12.12d);
|
||||
OrderDetail newDetail = new OrderDetail(p, 899, BigDecimal.valueOf(12.12d));
|
||||
// newDetail.setOrder(order);
|
||||
order.addDetail(newDetail);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
drop view order_agg_vw if exists;
|
||||
</ddl-script>
|
||||
|
||||
<ddl-script name="order views" platforms="db2,h2,postgres,oracle,mysql,mariadb,nuodb,yugabyte">
|
||||
<ddl-script name="order views" platforms="db2,h2,postgres,oracle,mysql,mariadb,nuodb,yugabyte,cockroach">
|
||||
create or replace view order_agg_vw as
|
||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||
sum(d.ship_qty * d.unit_price) as ship_total
|
||||
|
||||
Reference in New Issue
Block a user