#1788 - ENH: Add support for NuoDB database platform

This commit is contained in:
rob bygrave committed 2019-08-11 16:24:37 +12:00
1 parent fea840c859
commit c640524bfc
50 files changed
+371 -54

No files matched your search

+4
View File
@@ -170,6 +170,10 @@ public abstract class BaseTestCase {
return Platform.ORACLE == platform();
}
public boolean isNuoDb() {
return Platform.NUODB == platform();
}
public boolean isDb2() {
return Platform.DB2 == platform();
}
@@ -12,7 +12,7 @@ public class SqlRowBooleanTest extends BaseTestCase {
SqlQuery sqlQuery;
if (isSqlServer()) {
sqlQuery = Ebean.createSqlQuery("SELECT 1 AS ISNT_NULL");
} else if (isOracle()) {
} else if (isOracle() || isNuoDb()) {
sqlQuery = Ebean.createSqlQuery("SELECT 1 AS ISNT_NULL from dual");
} else if (isDb2()) {
sqlQuery = Ebean.createSqlQuery("SELECT 1 AS ISNT_NULL from SYSIBM.SYSDUMMY1");
@@ -50,7 +50,7 @@ public class DbMigrationTest extends BaseTestCase {
}
}
@IgnorePlatform(Platform.ORACLE)
@IgnorePlatform({Platform.ORACLE, Platform.NUODB})
@Test
public void testRunMigration() throws IOException {
// first clean up previously created objects
@@ -37,7 +37,7 @@ public class CacheBeanDataTest extends BaseTestCase {
c.setSmallnote("somenote");
Address billingAddress = new Address();
billingAddress.setId((short) 12);
billingAddress.setId(12);
billingAddress.setCity("Auckland");
billingAddress.setCountry(server.getReference(Country.class, "NZ"));
billingAddress.setLine1("92 Someplace Else");
@@ -31,7 +31,7 @@ public class CachedBeanDataFromBeanTest extends BaseTestCase {
customer.setAnniversary(largeDate);
Address billingAddress = new Address();
billingAddress.setId(Short.valueOf("12"));
billingAddress.setId(12);
billingAddress.setCity("SomePlace");
customer.setBillingAddress(billingAddress);
+17
View File
@@ -0,0 +1,17 @@
package main;
import io.ebean.docker.commands.NuoDBConfig;
import io.ebean.docker.commands.NuoDBContainer;
public class StartNuoDB {
public static void main(String[] args) {
NuoDBConfig config = new NuoDBConfig();
config.setDbName("unit");
NuoDBContainer container = new NuoDBContainer(config);
container.stopRemove();
container.startWithDropCreate();
}
}
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertNotNull;
public class TestAggregateFormula extends BaseTestCase {
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.NUODB})
@Test
public void minDistinctOrderByNulls() {
@@ -29,7 +29,7 @@ public class TestAssocOneEqExpression extends BaseTestCase {
Assert.assertTrue(sql.contains("where t0.kcustomer_id = ?"));
Address b = new Address();
b.setId((short) 1);
b.setId(1);
Query<Order> q2 = Ebean.find(Order.class)
.where().eq("customer.billingAddress", b)
@@ -22,7 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
@IgnorePlatform(Platform.HANA)
@IgnorePlatform({Platform.HANA, Platform.NUODB})
@Test
public void testBatchScenarioWithSavepoint() throws SQLException {
server().save(createEntityWithName("conflict", "before"));
@@ -52,6 +52,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
assertThat(winner.getDescription()).isEqualTo("after");
}
@IgnorePlatform(Platform.NUODB)
@Test
public void testBatchedInsertFailure() {
server().save(createEntityWithName("foo"));
@@ -60,6 +61,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
});
}
@IgnorePlatform(Platform.NUODB)
@Test
public void testBatchedUpdateFailure() {
server().save(createEntityWithName("bla"));
@@ -71,6 +73,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
});
}
@IgnorePlatform(Platform.NUODB)
@Test
public void testBatchedDeleteFailure() {
final EOptOneC c = new EOptOneC();
+3 -1
View File
@@ -2,6 +2,7 @@ package org.tests.cache;
import io.ebean.BaseTestCase;
import io.ebean.CacheMode;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.bean.BeanCollection;
import io.ebean.cache.ServerCache;
@@ -52,6 +53,7 @@ public class TestQueryCache extends BaseTestCase {
@Test
public void findSingleAttribute() {
DB.find(EColAB.class).delete();
new EColAB("03", "SingleAttribute").save();
new EColAB("03", "SingleAttribute").save();
@@ -260,11 +262,11 @@ public class TestQueryCache extends BaseTestCase {
@Test
public void findIds() {
DB.find(EColAB.class).delete();
new EColAB("03", "someId").save();
new EColAB("04", "someId").save();
new EColAB("05", "someId").save();
LoggedSqlCollector.start();
List<Integer> colA_first = Ebean.find(EColAB.class)
@@ -2,6 +2,8 @@ package org.tests.cascade;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import io.ebean.bean.BeanCollection;
import org.tests.model.basic.TSDetailTwo;
import org.tests.model.basic.TSMasterTwo;
@@ -13,6 +15,7 @@ import java.util.Set;
public class TestPrivateOwnedNoCascadeRemove extends BaseTestCase {
@IgnorePlatform(Platform.NUODB)
@Test
public void test() {
@@ -1,7 +1,7 @@
package org.tests.compositekeys;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.DB;
import org.junit.Test;
import org.tests.model.basic.CKeyParent;
import org.tests.model.basic.CKeyParentId;
@@ -24,20 +24,21 @@ public class TestCKeyDelete extends BaseTestCase {
p.setId(id);
p.setName("testDelete");
Ebean.save(p);
DB.save(p);
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
CKeyParent found = DB.find(CKeyParent.class).where().idEq(searchId).findOne();
assertNotNull(found);
Ebean.delete(CKeyParent.class, searchId);
DB.delete(CKeyParent.class, searchId);
CKeyParent notFound = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
CKeyParent notFound = DB.find(CKeyParent.class).where().idEq(searchId).findOne();
assertNull(notFound);
}
@Test
public void testDeleteWhere() {
DB.truncate(CKeyParent.class);
CKeyParentId id = new CKeyParentId(101, "deleteMe2");
CKeyParentId searchId = new CKeyParentId(101, "deleteMe2");
@@ -46,18 +47,18 @@ public class TestCKeyDelete extends BaseTestCase {
p.setId(id);
p.setName("testDelete");
Ebean.save(p);
DB.save(p);
List<CKeyParentId> ids = Ebean.find(CKeyParent.class).where().eq("id.oneKey", 101).findIds();
List<CKeyParentId> ids = DB.find(CKeyParent.class).where().eq("id.oneKey", 101).findIds();
assertThat(ids).hasSize(1);
CKeyParentId foundId = ids.get(0);
assertThat(foundId.getOneKey()).isEqualTo(101);
assertThat(foundId.getTwoKey()).isEqualTo("deleteMe2");
Ebean.createQuery(CKeyParent.class).where().eq("id.oneKey", 101).delete();
DB.createQuery(CKeyParent.class).where().eq("id.oneKey", 101).delete();
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
CKeyParent found = DB.find(CKeyParent.class).where().idEq(searchId).findOne();
assertNull(found);
}
}
@@ -2,6 +2,8 @@ package org.tests.ddl;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -82,6 +84,7 @@ public class TestForeignKeyModes extends BaseTestCase {
assertThat(sql.get(1)).contains("delete from dfk_none_via_mto_m where id=?");
}
@IgnorePlatform(Platform.NUODB)
@Test
public void setNullOnDelete() {
@@ -99,6 +102,7 @@ public class TestForeignKeyModes extends BaseTestCase {
assertThat(found.getOne()).isNull();
}
@IgnorePlatform(Platform.NUODB)
@Test
public void onDeleteCascade() {
@@ -47,7 +47,7 @@ public class TestPathExpression {
assertEquals(c1.getStatus(), Customer.Status.ACTIVE);
assertEquals(c1.getBillingAddress().getLine1(), "12 someplace");
assertEquals(c1.getBillingAddress().getCity(), "Auckland");
assertEquals(c1.getBillingAddress().getId(), Short.valueOf("4"));
assertEquals(c1.getBillingAddress().getId(), Integer.valueOf("4"));
assertEquals(c1.getBillingAddress().getCountry().getCode(), "NZ");
assertEquals(c1.getBillingAddress().getCountry().getName(), "New Zealand");
@@ -57,7 +57,7 @@ public class TestPathExpression {
public void pathGet() {
Address billingAddress = new Address();
billingAddress.setId((short) 12);
billingAddress.setId(12);
billingAddress.setLine1("line1");
billingAddress.setCity("Auckland");
@@ -72,7 +72,7 @@ public class TestPathExpression {
EntityBean e0 = (EntityBean) c0;
assertEquals(line1.pathGet(e0), "line1");
assertEquals(city.pathGet(e0), "Auckland");
assertEquals(billingId.pathGet(e0), Short.valueOf("12"));
assertEquals(billingId.pathGet(e0), Integer.valueOf("12"));
assertEquals(beanType.getExpressionPath("billingAddress.country.code").pathGet(e0), "NZ");
@@ -1,8 +1,11 @@
package org.tests.insert;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.DataIntegrityException;
import io.ebean.Ebean;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import org.junit.Test;
import org.tests.model.basic.Customer;
import org.tests.model.basic.Order;
@@ -11,6 +14,7 @@ import org.tests.model.basic.ResetBasicData;
public class TestInsertDataIntegrityException extends BaseTestCase {
@IgnorePlatform(Platform.NUODB)
@Test(expected = DataIntegrityException.class)
public void insert_invalidForeignKey() {
@@ -23,6 +27,6 @@ public class TestInsertDataIntegrityException extends BaseTestCase {
order.setStatus(Order.Status.NEW);
order.setCustomer(invalidCustomer);
Ebean.save(order);
DB.save(order);
}
}
@@ -1,6 +1,7 @@
package org.tests.m2m;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.SqlQuery;
import io.ebean.SqlRow;
@@ -16,6 +17,8 @@ public class TestM2MDeleteCascadeFromParent extends BaseTestCase {
@Test
public void test() {
DB.truncate("mny_b_mny_c","mny_c","mny_b", "mny_a");
MnyC c0 = new MnyC();
c0.setName("c0");
c0.save();
@@ -2,6 +2,8 @@ package org.tests.m2m;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import org.tests.model.basic.MnocRole;
import org.tests.model.basic.MnocUser;
import org.junit.Assert;
@@ -12,6 +14,7 @@ import java.util.List;
public class TestM2MDeleteNoCascade extends BaseTestCase {
@IgnorePlatform(Platform.NUODB)
@Test
public void test() {
@@ -25,7 +25,7 @@ import java.sql.Timestamp;
public class Address {
@Id
Short id;
Integer id;
@Size(max = 100)
@Column(name = "line_1")
@@ -55,14 +55,14 @@ public class Address {
/**
* Return id.
*/
public Short getId() {
public Integer getId() {
return id;
}
/**
* Set id.
*/
public void setId(Short id) {
public void setId(Integer id) {
this.id = id;
}
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.Transaction;
import org.ebeantest.LoggedSqlCollector;
@@ -18,6 +19,7 @@ public class TestElementCollectionBasic extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcPerson.class);
eventLog();
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.annotation.PersistBatch;
import io.ebeaninternal.api.SpiEbeanServer;
@@ -15,6 +16,7 @@ public class TestElementCollectionBasicCache extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcPerson.class);
EcPerson person = new EcPerson("Cache1");
person.getPhoneNumbers().add("021 1234");
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -15,6 +16,7 @@ public class TestElementCollectionBasicMap extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcmPerson.class);
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -13,6 +14,7 @@ public class TestElementCollectionBasicMapAsLob extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcmcPerson.class);
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.annotation.PersistBatch;
import io.ebeaninternal.api.SpiEbeanServer;
@@ -15,6 +16,7 @@ public class TestElementCollectionBasicMapCache extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcmPerson.class);
EcmPerson person = new EcmPerson("CacheMap");
person.getPhoneNumbers().put("home", "021 1234");
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -14,6 +15,7 @@ public class TestElementCollectionBasicSet extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcsPerson.class);
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -13,6 +14,7 @@ public class TestElementCollectionEmbeddedList extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcblPerson.class);
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -13,6 +14,7 @@ public class TestElementCollectionEmbeddedListCache extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcblPerson.class);
EcblPerson person = new EcblPerson("CacheL");
person.getPhoneNumbers().add(new EcPhone("64", "021","1234"));
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -14,6 +15,7 @@ public class TestElementCollectionEmbeddedMap extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcbmPerson.class);
LoggedSqlCollector.start();
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -13,6 +14,7 @@ public class TestElementCollectionEmbeddedMapCache extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcbmPerson.class);
EcbmPerson person = new EcbmPerson("Cache1");
person.getPhoneNumbers().put("home", new EcPhone("64", "021", "1234"));
@@ -1,6 +1,7 @@
package org.tests.model.elementcollection;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.junit.Test;
@@ -10,6 +11,7 @@ public class TestElementCollectionEnumSet extends BaseTestCase {
@Test
public void test() {
DB.truncate(EcEnumPerson.class);
EcEnumPerson person = new EcEnumPerson("Enum Person");
person.getTags().add(EcEnumPerson.Tags.BLUE);
@@ -1,17 +1,18 @@
package org.tests.model.lazywithid;
import static org.junit.Assert.assertEquals;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import org.junit.Test;
import java.util.List;
import org.junit.Test;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import static org.junit.Assert.assertEquals;
public class TestColumnIdName extends BaseTestCase {
@Test
public void test() {
DB.truncate(Tune.class);
Tune tune = new Tune();
tune.getLoonies().add(new Looney("Taz"));
@@ -41,7 +41,7 @@ public class TestOrderByWithDistinct extends BaseTestCase {
}
@Test
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER}) // do not support nulls first/last
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER, Platform.NUODB}) // do not support nulls first/last
public void testDistinctOn() {
MRole role = Ebean.getReference(MRole.class, 1);
@@ -26,7 +26,7 @@ public class TestWhereLikeWithSlash extends BaseTestCase {
Query<EBasic> query1 = Ebean.find(EBasic.class).where().like("name", "slash\\mon%").query();
List<EBasic> list1 = query1.findList();
if (!isMySql()) {
if (!isMySql() && !isNuoDb()) {
// For mysql this assert depends on no_backslash_escapes setting so we won't assert here
// Still good on Postgres which was the original issue
assertEquals(1, list1.size());
@@ -1,6 +1,7 @@
package org.tests.repository;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.Test;
import org.tests.model.basic.Customer;
import org.tests.model.basic.ResetBasicData;
@@ -15,6 +16,7 @@ public class TestBeanRepository extends BaseTestCase {
@Test
public void test() {
DB.find(Customer.class).where().in("name", "c0", "c1").delete();
ResetBasicData.reset();
@@ -1,6 +1,7 @@
package org.tests.softdelete;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.Query;
import io.ebean.SqlQuery;
@@ -113,6 +114,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
@Test
public void testFindSoftDeleted() {
DB.truncate(EBasicSoftDelete.class);
EBasicSoftDelete bean = new EBasicSoftDelete();
bean.setName("softDelFetch");