#2004 - MariaDb specific platform with @History support (initial) (#2023)

#2004 - MariaDb specific platform with @History support (initial)
This commit is contained in:
Rob Bygrave
2020-06-19 23:20:07 +12:00
committed by GitHub
parent f445c118a0
commit 32ce1f1d59
29 changed files with 347 additions and 110 deletions
+4
View File
@@ -206,6 +206,10 @@ public abstract class BaseTestCase {
return Platform.MYSQL == platform();
}
public boolean isMariaDB() {
return Platform.MARIADB == platform();
}
public boolean isHana() {
return Platform.HANA == platform();
}
+3 -3
View File
@@ -168,7 +168,7 @@ public class UpdateQueryTest extends BaseTestCase {
assertSql(query).contains("update o_customer cust set status=?, updtime=? where id > ?");
}
@IgnorePlatform(Platform.MYSQL)
@IgnorePlatform({Platform.MYSQL, Platform.MARIADB})
@Test
public void withJoin() {
@@ -214,7 +214,7 @@ public class UpdateQueryTest extends BaseTestCase {
assertSql(sql.get(0)).contains("update o_customer set status=? where id in (select t0.id from o_customer t0 left join o_address t1 on t1.id = t0.billing_address_id where t1.country_code = ? and t0.id > ? limit 100)");
}
@ForPlatform({Platform.H2, Platform.POSTGRES, Platform.MYSQL})
@ForPlatform({Platform.H2, Platform.POSTGRES, Platform.MYSQL, Platform.MARIADB})
@Test
public void simpleWithLimit() {
@@ -230,7 +230,7 @@ public class UpdateQueryTest extends BaseTestCase {
.update();
final List<String> sql = LoggedSqlCollector.stop();
if (isMySql() || isH2()) {
if (isMySql() || isH2() || isMariaDB()) {
assertSql(sql.get(0)).contains("update o_customer set status=? where id > ? limit 100");
} else {
assertSql(sql.get(0)).contains("update o_customer set status=? where id in (select t0.id from o_customer t0 where t0.id > ? limit 100)");
@@ -24,7 +24,7 @@ public class DbMigrationTest extends BaseTestCase {
server().script().runScript(scriptName, content, useAutoCommit);
}
@IgnorePlatform({Platform.ORACLE, Platform.NUODB})
@IgnorePlatform({Platform.ORACLE, Platform.NUODB, Platform.MARIADB})
@Test
public void testRunMigration() throws IOException {
// first clean up previously created objects
+18
View File
@@ -0,0 +1,18 @@
package main;
import io.ebean.docker.commands.MariaDBConfig;
import io.ebean.docker.commands.MariaDBContainer;
public class StartMariaDb {
public static void main(String[] args) {
MariaDBConfig config = new MariaDBConfig("10.5");
config.setDbName("unit");
config.setUser("unit");
config.setPassword("unit");
MariaDBContainer container = new MariaDBContainer(config);
container.startWithDropCreate();
}
}
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertNotNull;
public class TestAggregateFormula extends BaseTestCase {
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.NUODB})
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB, Platform.NUODB})
@Test
public void minDistinctOrderByNulls() {
@@ -49,7 +49,7 @@ public class TestMetaAnnotation extends BaseTestCase {
* This test writes 101 spaces to "line1" which is annotated with &#64;Size(max=100).
*/
@Test
@IgnorePlatform({Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL}) // pg & mssql does not fail if string is too long.
@IgnorePlatform({Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB}) // pg & mssql does not fail if string is too long.
public void testWrite101SpacesToLine1() {
Address address = new Address();
@@ -66,7 +66,7 @@ public class TestMetaAnnotation extends BaseTestCase {
* This test writes 101 spaces to "line1" which is meta-annotated with {@link SizeMedium}.
*/
@Test
@IgnorePlatform({Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL})
@IgnorePlatform({Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB})
public void testWrite101SpacesToLine2() {
Address address = new Address();
@@ -23,7 +23,7 @@ public class TestQueryForUpdate extends BaseTestCase {
@Test
@ForPlatform({Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL})
@ForPlatform({Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB})
public void testForUpdate() {
ResetBasicData.reset();
@@ -41,7 +41,7 @@ public class TestQueryForUpdate extends BaseTestCase {
}
@Test
@ForPlatform({ Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL})
@ForPlatform({ Platform.H2, Platform.ORACLE, Platform.POSTGRES, Platform.SQLSERVER, Platform.MYSQL, Platform.MARIADB})
public void testForUpdate_when_alreadyInPC() {
EBasic basic = new EBasic("test PC cache");
@@ -26,7 +26,7 @@ public class TestDefaults extends BaseTestCase {
final List<String> current = LoggedSqlCollector.current();
assertThat(current).isNotEmpty();
if (isMySql()) {
if (isMySql() || isMariaDB()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft values (default);");
} else if (isSqlServer()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft (id) values (?)");
@@ -27,7 +27,7 @@ public class TestDeleteByQuery extends BaseTestCase {
}
@Test
@IgnorePlatform(Platform.MYSQL)
@IgnorePlatform({Platform.MYSQL, Platform.MARIADB})
public void deleteWithLimit() {
createUser("deleteWithLimit1");
createUser("deleteWithLimit2");
@@ -41,7 +41,7 @@ public class TestOrderByWithDistinct extends BaseTestCase {
}
@Test
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER, Platform.NUODB}) // do not support nulls first/last
@IgnorePlatform({Platform.MYSQL, Platform.MARIADB, 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() && !isNuoDb()) {
if (!isMySql() && !isNuoDb() && !isMariaDB()) {
// 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());
@@ -117,7 +117,7 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
}
@Test
@IgnorePlatform({Platform.MYSQL, Platform.SQLSERVER})
@IgnorePlatform({Platform.MYSQL, Platform.MARIADB, Platform.SQLSERVER})
public void test_upperCaseSql() {
ResetBasicData.reset();
+20 -17
View File
@@ -36,6 +36,9 @@ public class TestNewTypes extends BaseTestCase {
@Test
public void testInsertUpdate() throws InterruptedException {
DB.find(SomeNewTypesBean.class).delete();
SomeNewTypesBean bean = new SomeNewTypesBean();
bean.setLocalDate(LocalDate.now());
bean.setLocalDateTime(LocalDateTime.now());
@@ -65,55 +68,55 @@ public class TestNewTypes extends BaseTestCase {
DB.save(bean);
Thread.sleep(DB_CLOCK_DELTA); // wait, to ensure that instant < Instant.now()
List<SomeNewTypesBean> list = DB.find(SomeNewTypesBean.class).where().lt("instant", Instant.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("localDate", LocalDate.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().lt("localDateTime", LocalDateTime.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().lt("offsetDateTime", OffsetDateTime.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().lt("zonedDateTime", ZonedDateTime.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("sqlDate", bean.getSqlDate()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("sqlTime", bean.getSqlTime()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("localTime", LocalTime.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("zoneId", ZoneId.systemDefault().getId()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("zoneOffset", ZonedDateTime.now().getOffset()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("yearMonth", YearMonth.of(2014, 9)).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("monthDay", MonthDay.of(9,22)).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("year", Year.now()).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().le("month", Month.SEPTEMBER).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("path", Paths.get(TEMP_PATH)).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("period", Period.of(4,3,2)).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
list = DB.find(SomeNewTypesBean.class).where().eq("duration", Duration.ofMinutes(5)).findList();
assertTrue(!list.isEmpty());
assertThat(list).isNotEmpty();
SomeNewTypesBean fetched = DB.find(SomeNewTypesBean.class, bean.getId());