mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 14:46:25 +00:00
Merge remote-tracking branch 'upstream/master' into tmp3
# Conflicts: # ebean-test/src/test/java/org/tests/model/tevent/TEventOne.java
This commit is contained in:
commit
04d8878689
23 files changed
+69
-74
No files matched your search
@@ -11,10 +11,6 @@ public class CockroachPlatform extends PostgresPlatform {
|
|||||||
public CockroachPlatform() {
|
public CockroachPlatform() {
|
||||||
super();
|
super();
|
||||||
this.platform = Platform.COCKROACH;
|
this.platform = Platform.COCKROACH;
|
||||||
// no like escape clause supported
|
|
||||||
this.likeSpecialCharacters = new char[]{'%', '_'};
|
|
||||||
this.likeClauseRaw = "like ?";
|
|
||||||
this.likeClauseEscaped = "like ?";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +18,7 @@ public class CockroachPlatform extends PostgresPlatform {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isDdlAutoCommit() {
|
public boolean isDdlAutoCommit() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ public final class InternalConfiguration {
|
|||||||
|
|
||||||
private MultiValueBind createMultiValueBind(Platform platform) {
|
private MultiValueBind createMultiValueBind(Platform platform) {
|
||||||
// only Postgres at this stage
|
// only Postgres at this stage
|
||||||
if (platform.base() == Platform.POSTGRES || platform.base() == Platform.YUGABYTE) {
|
if (platform.base() == Platform.POSTGRES || platform.base() == Platform.YUGABYTE || platform.base() == Platform.COCKROACH) {
|
||||||
return new PostgresMultiValueBind();
|
return new PostgresMultiValueBind();
|
||||||
}
|
}
|
||||||
return new MultiValueBind();
|
return new MultiValueBind();
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
int rc = request.executeOrQueue();
|
int rc = request.executeOrQueue();
|
||||||
request.commitTransIfRequired();
|
request.commitTransIfRequired();
|
||||||
return rc;
|
return rc;
|
||||||
|
} catch (Throwable e) {
|
||||||
} catch (RuntimeException e) {
|
|
||||||
request.rollbackTransIfRequired();
|
request.rollbackTransIfRequired();
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -383,8 +382,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
req.resetDepth();
|
req.resetDepth();
|
||||||
req.commitTransIfRequired();
|
req.commitTransIfRequired();
|
||||||
req.flushBatchOnCascade();
|
req.flushBatchOnCascade();
|
||||||
|
} catch (Throwable ex) {
|
||||||
} catch (RuntimeException ex) {
|
|
||||||
req.rollbackTransIfRequired();
|
req.rollbackTransIfRequired();
|
||||||
throw ex;
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -420,8 +418,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
req.resetDepth();
|
req.resetDepth();
|
||||||
req.commitTransIfRequired();
|
req.commitTransIfRequired();
|
||||||
req.flushBatchOnCascade();
|
req.flushBatchOnCascade();
|
||||||
|
} catch (Throwable ex) {
|
||||||
} catch (RuntimeException ex) {
|
|
||||||
req.rollbackTransIfRequired();
|
req.rollbackTransIfRequired();
|
||||||
throw ex;
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -559,7 +556,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
req.flushBatchOnCascade();
|
req.flushBatchOnCascade();
|
||||||
return rows;
|
return rows;
|
||||||
|
|
||||||
} catch (RuntimeException ex) {
|
} catch (Throwable ex) {
|
||||||
req.rollbackTransIfRequired();
|
req.rollbackTransIfRequired();
|
||||||
throw ex;
|
throw ex;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ final class CQueryBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isPlatformDistinctOn() {
|
boolean isPlatformDistinctOn() {
|
||||||
return dbPlatform.isPlatform(Platform.POSTGRES) || dbPlatform.isPlatform(Platform.YUGABYTE);
|
return dbPlatform.isPlatform(Platform.POSTGRES) || dbPlatform.isPlatform(Platform.YUGABYTE) || dbPlatform.isPlatform(Platform.COCKROACH);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPlatformDistinctNoLobs() {
|
boolean isPlatformDistinctNoLobs() {
|
||||||
|
|||||||
@@ -209,7 +209,8 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
|
|
||||||
private boolean isPostgresCompatible(DatabasePlatform databasePlatform) {
|
private boolean isPostgresCompatible(DatabasePlatform databasePlatform) {
|
||||||
return databasePlatform.isPlatform(Platform.POSTGRES)
|
return databasePlatform.isPlatform(Platform.POSTGRES)
|
||||||
|| databasePlatform.isPlatform(Platform.YUGABYTE);
|
|| databasePlatform.isPlatform(Platform.YUGABYTE)
|
||||||
|
|| databasePlatform.isPlatform(Platform.COCKROACH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hstoreSupport() {
|
private boolean hstoreSupport() {
|
||||||
|
|||||||
+1
-13
@@ -21,21 +21,9 @@ public class CockroachDdl extends PlatformDdl {
|
|||||||
return NativeDbArray.logicalToNative(logicalArrayType);
|
return NativeDbArray.logicalToNative(logicalArrayType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map bigint, integer and smallint all into serial.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String asIdentityColumn(String columnDefn, DdlIdentity identity) {
|
public String asIdentityColumn(String columnDefn, DdlIdentity identity) {
|
||||||
if ("bigint".equalsIgnoreCase(columnDefn)) {
|
return asIdentityStandardOptions(columnDefn, identity);
|
||||||
return "serial";
|
|
||||||
}
|
|
||||||
if ("integer".equalsIgnoreCase(columnDefn)) {
|
|
||||||
return "serial";
|
|
||||||
}
|
|
||||||
if ("smallint".equalsIgnoreCase(columnDefn)) {
|
|
||||||
return "serial";
|
|
||||||
}
|
|
||||||
return columnDefn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPostgresCompatible() {
|
public boolean isPostgresCompatible() {
|
||||||
return isPostgres() || isYugabyte();
|
return isPostgres() || isYugabyte() || isCockroach();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPostgres() {
|
public boolean isPostgres() {
|
||||||
@@ -211,6 +211,10 @@ public abstract class BaseTestCase {
|
|||||||
return Platform.YUGABYTE == platform().base();
|
return Platform.YUGABYTE == platform().base();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCockroach() {
|
||||||
|
return Platform.COCKROACH == platform().base();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMySql() {
|
public boolean isMySql() {
|
||||||
return Platform.MYSQL == platform();
|
return Platform.MYSQL == platform();
|
||||||
}
|
}
|
||||||
@@ -281,7 +285,7 @@ public abstract class BaseTestCase {
|
|||||||
* Platform specific IN clause assert.
|
* Platform specific IN clause assert.
|
||||||
*/
|
*/
|
||||||
protected void platformAssertIn(String sql, String containsIn) {
|
protected void platformAssertIn(String sql, String containsIn) {
|
||||||
if (isPostgres() || isYugabyte()) {
|
if (isPostgresCompatible()) {
|
||||||
assertThat(sql).contains(containsIn+" = any(");
|
assertThat(sql).contains(containsIn+" = any(");
|
||||||
} else {
|
} else {
|
||||||
assertThat(sql).contains(containsIn+" in ");
|
assertThat(sql).contains(containsIn+" in ");
|
||||||
@@ -293,7 +297,7 @@ public abstract class BaseTestCase {
|
|||||||
* Platform specific NOT IN clause assert.
|
* Platform specific NOT IN clause assert.
|
||||||
*/
|
*/
|
||||||
protected void platformAssertNotIn(String sql, String containsIn) {
|
protected void platformAssertNotIn(String sql, String containsIn) {
|
||||||
if (isPostgres() || isYugabyte()) {
|
if (isPostgresCompatible()) {
|
||||||
assertThat(sql).contains(containsIn+" != all(");
|
assertThat(sql).contains(containsIn+" != all(");
|
||||||
} else {
|
} else {
|
||||||
assertThat(sql).contains(containsIn+" not in ");
|
assertThat(sql).contains(containsIn+" not in ");
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
//import io.ebean.docker.commands.CockroachConfig;
|
import io.ebean.docker.commands.CockroachConfig;
|
||||||
//import io.ebean.docker.commands.CockroachContainer;
|
import io.ebean.docker.commands.CockroachContainer;
|
||||||
|
|
||||||
public class StartCockroach {
|
public class StartCockroach {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
// CockroachConfig config = new CockroachConfig();
|
CockroachConfig config = new CockroachConfig("v21.2.4");
|
||||||
// config.setDbName("unit");
|
config.setDbName("unit");
|
||||||
//
|
|
||||||
// CockroachContainer container = new CockroachContainer(config);
|
CockroachContainer container = new CockroachContainer(config);
|
||||||
// container.startWithDropCreate();
|
container.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||||||
|
|
||||||
public class TestAggregateFormula extends BaseTestCase {
|
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
|
@Test
|
||||||
public void minDistinctOrderByNulls() {
|
public void minDistinctOrderByNulls() {
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class TestQueryUsingConnection extends BaseTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnorePlatform(Platform.SQLSERVER)
|
@IgnorePlatform({Platform.SQLSERVER, Platform.COCKROACH})
|
||||||
@Test
|
@Test
|
||||||
public void usingTransaction() {
|
public void usingTransaction() {
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class TestEncrypt extends BaseTestCase {
|
|||||||
assertThat(loggedSql.get(1)).contains("left join e_basicenc t1 on t1.id = t0.other_id");
|
assertThat(loggedSql.get(1)).contains("left join e_basicenc t1 on t1.id = t0.other_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||||
@Test
|
@Test
|
||||||
public void asDto() {
|
public void asDto() {
|
||||||
DB.find(EBasicEncrypt.class).delete();
|
DB.find(EBasicEncrypt.class).delete();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class TestJsonMapBasic extends BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ForPlatform(Platform.POSTGRES)
|
@ForPlatform({Platform.POSTGRES, Platform.COCKROACH})
|
||||||
public void whereManyPredicatePg() {
|
public void whereManyPredicatePg() {
|
||||||
|
|
||||||
bean.setName("own1");
|
bean.setName("own1");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.ebean.annotation.DocEmbedded;
|
|||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +28,7 @@ public class OrderDetail implements Serializable {
|
|||||||
|
|
||||||
Integer shipQty;
|
Integer shipQty;
|
||||||
|
|
||||||
Double unitPrice;
|
BigDecimal unitPrice;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@DocEmbedded(doc = "id,name,sku")
|
@DocEmbedded(doc = "id,name,sku")
|
||||||
@@ -41,7 +42,7 @@ public class OrderDetail implements Serializable {
|
|||||||
public OrderDetail() {
|
public OrderDetail() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderDetail(Product product, Integer orderQty, Double unitPrice) {
|
public OrderDetail(Product product, Integer orderQty, BigDecimal unitPrice) {
|
||||||
this.product = product;
|
this.product = product;
|
||||||
this.orderQty = orderQty;
|
this.orderQty = orderQty;
|
||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
@@ -89,11 +90,11 @@ public class OrderDetail implements Serializable {
|
|||||||
this.shipQty = shipQty;
|
this.shipQty = shipQty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getUnitPrice() {
|
public BigDecimal getUnitPrice() {
|
||||||
return unitPrice;
|
return unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUnitPrice(Double unitPrice) {
|
public void setUnitPrice(BigDecimal unitPrice) {
|
||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import io.ebean.Database;
|
|||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
import org.tests.model.basic.Order.Status;
|
import org.tests.model.basic.Order.Status;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -213,9 +214,9 @@ public class ResetBasicData {
|
|||||||
order.setOrderDate(Date.valueOf("2018-07-01"));
|
order.setOrderDate(Date.valueOf("2018-07-01"));
|
||||||
|
|
||||||
List<OrderDetail> details = new ArrayList<>();
|
List<OrderDetail> details = new ArrayList<>();
|
||||||
details.add(new OrderDetail(product1, 5, 10.50));
|
details.add(new OrderDetail(product1, 5, BigDecimal.valueOf(10.50)));
|
||||||
details.add(new OrderDetail(product2, 3, 1.10));
|
details.add(new OrderDetail(product2, 3, BigDecimal.valueOf(1.10)));
|
||||||
details.add(new OrderDetail(product3, 1, 2.00));
|
details.add(new OrderDetail(product3, 1, BigDecimal.valueOf(2.00)));
|
||||||
order.setDetails(details);
|
order.setDetails(details);
|
||||||
order.addShipment(new OrderShipment());
|
order.addShipment(new OrderShipment());
|
||||||
DB.save(order);
|
DB.save(order);
|
||||||
@@ -231,7 +232,7 @@ public class ResetBasicData {
|
|||||||
order.setOrderDate(Date.valueOf("2018-06-01"));
|
order.setOrderDate(Date.valueOf("2018-06-01"));
|
||||||
|
|
||||||
List<OrderDetail> details = new ArrayList<>();
|
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.setDetails(details);
|
||||||
order.addShipment(new OrderShipment());
|
order.addShipment(new OrderShipment());
|
||||||
DB.save(order);
|
DB.save(order);
|
||||||
@@ -247,9 +248,9 @@ public class ResetBasicData {
|
|||||||
order.setOrderDate(Date.valueOf("2018-07-02"));
|
order.setOrderDate(Date.valueOf("2018-07-02"));
|
||||||
|
|
||||||
List<OrderDetail> details = new ArrayList<>();
|
List<OrderDetail> details = new ArrayList<>();
|
||||||
details.add(new OrderDetail(product1, 3, 10.50));
|
details.add(new OrderDetail(product1, 3, BigDecimal.valueOf(10.50)));
|
||||||
details.add(new OrderDetail(product3, 40, 2.10));
|
details.add(new OrderDetail(product3, 40, BigDecimal.valueOf(2.10)));
|
||||||
details.add(new OrderDetail(product1, 5, 10.00));
|
details.add(new OrderDetail(product1, 5, BigDecimal.valueOf(10.00)));
|
||||||
order.setDetails(details);
|
order.setDetails(details);
|
||||||
order.addShipment(new OrderShipment());
|
order.addShipment(new OrderShipment());
|
||||||
DB.save(order);
|
DB.save(order);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class TestHistoryExclude extends BaseTestCase {
|
|||||||
linkFound.getDocs().size();
|
linkFound.getDocs().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||||
@Test
|
@Test
|
||||||
public void testAsOfThenLazy() {
|
public void testAsOfThenLazy() {
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class TestHistoryInclude extends BaseTestCase {
|
|||||||
assertThat(linkFound.getDocs().size()).isEqualTo(2);
|
assertThat(linkFound.getDocs().size()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||||
@Test
|
@Test
|
||||||
public void testAsOfThenLazy() {
|
public void testAsOfThenLazy() {
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
public class TestHistoryOneToMany extends BaseTestCase {
|
public class TestHistoryOneToMany extends BaseTestCase {
|
||||||
|
|
||||||
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
|
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
|
||||||
@Test
|
@Test
|
||||||
public void test() throws InterruptedException {
|
public void test() throws InterruptedException {
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class TEventMany {
|
public class TEventMany {
|
||||||
@@ -18,12 +19,12 @@ public class TEventMany {
|
|||||||
|
|
||||||
int myUnits;
|
int myUnits;
|
||||||
|
|
||||||
double amount;
|
BigDecimal amount;
|
||||||
|
|
||||||
@Version
|
@Version
|
||||||
Long version;
|
Long version;
|
||||||
|
|
||||||
public TEventMany(String description, int myUnits, double amount) {
|
public TEventMany(String description, int myUnits, BigDecimal amount) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.myUnits = myUnits;
|
this.myUnits = myUnits;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
@@ -61,11 +62,11 @@ public class TEventMany {
|
|||||||
this.myUnits = myUnits;
|
this.myUnits = myUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getAmount() {
|
public BigDecimal getAmount() {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAmount(double amount) {
|
public void setAmount(BigDecimal amount) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.tests.model.tevent;
|
|||||||
import io.ebean.annotation.Aggregation;
|
import io.ebean.annotation.Aggregation;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -33,10 +34,10 @@ public class TEventOne {
|
|||||||
Long count;
|
Long count;
|
||||||
|
|
||||||
@Aggregation("sum(logs.myUnits)")
|
@Aggregation("sum(logs.myUnits)")
|
||||||
Double totalUnits;
|
BigDecimal totalUnits;
|
||||||
|
|
||||||
@Aggregation("sum(logs.myUnits * logs.amount)")
|
@Aggregation("sum(logs.myUnits * logs.amount)")
|
||||||
Double totalAmount;
|
BigDecimal totalAmount;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
|
||||||
List<TEventMany> logs;
|
List<TEventMany> logs;
|
||||||
@@ -72,11 +73,11 @@ public class TEventOne {
|
|||||||
return customFormula;
|
return customFormula;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getTotalUnits() {
|
public BigDecimal getTotalUnits() {
|
||||||
return totalUnits;
|
return totalUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getTotalAmount() {
|
public BigDecimal getTotalAmount() {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package org.tests.query;
|
|||||||
import io.ebean.BaseTestCase;
|
import io.ebean.BaseTestCase;
|
||||||
import io.ebean.DB;
|
import io.ebean.DB;
|
||||||
import io.ebean.Query;
|
import io.ebean.Query;
|
||||||
|
import io.ebean.annotation.IgnorePlatform;
|
||||||
|
import io.ebean.annotation.Platform;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.tests.model.basic.CKeyParent;
|
import org.tests.model.basic.CKeyParent;
|
||||||
import org.tests.model.basic.ResetBasicData;
|
import org.tests.model.basic.ResetBasicData;
|
||||||
@@ -37,6 +39,7 @@ public class TestQueryAlias extends BaseTestCase {
|
|||||||
assertThat(sql).contains("(myt0.one_key) in (select st0.one_key from ckey_parent st0)");
|
assertThat(sql).contains("(myt0.one_key) in (select st0.one_key from ckey_parent st0)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IgnorePlatform(Platform.COCKROACH)
|
||||||
@Test
|
@Test
|
||||||
public void testExistsWithConcat() {
|
public void testExistsWithConcat() {
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.tests.model.basic.ResetBasicData;
|
|||||||
import org.tests.model.tevent.TEventMany;
|
import org.tests.model.tevent.TEventMany;
|
||||||
import org.tests.model.tevent.TEventOne;
|
import org.tests.model.tevent.TEventOne;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,15 +25,15 @@ public class TestAggregationCount extends BaseTestCase {
|
|||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
TEventOne one = new TEventOne("first", TEventOne.Status.AA);
|
TEventOne one = new TEventOne("first", TEventOne.Status.AA);
|
||||||
one.getLogs().add(new TEventMany("all", 1, 10));
|
one.getLogs().add(new TEventMany("all", 1, BigDecimal.valueOf(10)));
|
||||||
one.getLogs().add(new TEventMany("be", 2, 12.2));
|
one.getLogs().add(new TEventMany("be", 2, BigDecimal.valueOf(12.2)));
|
||||||
one.getLogs().add(new TEventMany("add", 3, 13));
|
one.getLogs().add(new TEventMany("add", 3, BigDecimal.valueOf(13)));
|
||||||
DB.save(one);
|
DB.save(one);
|
||||||
|
|
||||||
TEventOne two = new TEventOne("second", TEventOne.Status.AA);
|
TEventOne two = new TEventOne("second", TEventOne.Status.AA);
|
||||||
two.getLogs().add(new TEventMany("at", 10, 10));
|
two.getLogs().add(new TEventMany("at", 10, BigDecimal.valueOf(10)));
|
||||||
two.getLogs().add(new TEventMany("add", 30, 13));
|
two.getLogs().add(new TEventMany("add", 30, BigDecimal.valueOf(13)));
|
||||||
two.getLogs().add(new TEventMany("alf", 30, 13));
|
two.getLogs().add(new TEventMany("alf", 30, BigDecimal.valueOf(13)));
|
||||||
DB.save(two);
|
DB.save(two);
|
||||||
|
|
||||||
TEventOne three = new TEventOne("thrird", TEventOne.Status.BB);
|
TEventOne three = new TEventOne("thrird", TEventOne.Status.BB);
|
||||||
@@ -53,7 +54,7 @@ public class TestAggregationCount extends BaseTestCase {
|
|||||||
for (TEventOne eventOne : list) {
|
for (TEventOne eventOne : list) {
|
||||||
// lazy loading on Aggregation properties
|
// lazy loading on Aggregation properties
|
||||||
// is not expected to work at this stage
|
// is not expected to work at this stage
|
||||||
Double totalAmount = eventOne.getTotalAmount();
|
BigDecimal totalAmount = eventOne.getTotalAmount();
|
||||||
assertThat(totalAmount).isNull();
|
assertThat(totalAmount).isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.tests.model.basic.*;
|
|||||||
import org.tests.model.basic.Order.Status;
|
import org.tests.model.basic.Order.Status;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@@ -36,14 +37,14 @@ public class TestTextJsonUpdateCascade extends TransactionalTestCase {
|
|||||||
|
|
||||||
OrderDetail orderDetail0 = order.getDetails().get(0);
|
OrderDetail orderDetail0 = order.getDetails().get(0);
|
||||||
orderDetail0.setShipQty(300);
|
orderDetail0.setShipQty(300);
|
||||||
orderDetail0.setUnitPrice(56.98d);
|
orderDetail0.setUnitPrice(BigDecimal.valueOf(56.98d));
|
||||||
|
|
||||||
// remove one of the details...
|
// remove one of the details...
|
||||||
OrderDetail removedDetail = order.getDetails().remove(2);
|
OrderDetail removedDetail = order.getDetails().remove(2);
|
||||||
assertNotNull(removedDetail);
|
assertNotNull(removedDetail);
|
||||||
|
|
||||||
Product p = DB.reference(Product.class, 1);
|
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);
|
// newDetail.setOrder(order);
|
||||||
order.addDetail(newDetail);
|
order.addDetail(newDetail);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
drop view order_agg_vw if exists;
|
drop view order_agg_vw if exists;
|
||||||
</ddl-script>
|
</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
|
create or replace view order_agg_vw as
|
||||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||||
sum(d.ship_qty * d.unit_price) as ship_total
|
sum(d.ship_qty * d.unit_price) as ship_total
|
||||||
|
|||||||
Reference in new issue
Block a user