mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2782 - Support MariaDB jdbc driver update - Batched JDBC SQLException translation, SqlRow BLOB reading
- Batched JDBC SQLException translation - Need to dig into nested exception to get cause error state - SqlRow BLOB reading - BLOB can come as LONGVARBINARY (TestRawSqlBuilder) - Fix test for history using system time (TestHistoryInsert) - Fix SqlQueryCancelTest - Fix TestSqlUpdateExceptions
This commit is contained in:
@@ -15,19 +15,23 @@ import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestHistoryInsert extends BaseTestCase {
|
||||
class TestHistoryInsert extends BaseTestCase {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(TestHistoryInsert.class);
|
||||
|
||||
private Timestamp currentDbSystemTime() {
|
||||
return DB.sqlQuery("select current_timestamp(6)").mapToScalar(Timestamp.class).findOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks like we MUST use useLegacyDatetimeCode=false ... in order for
|
||||
* the correct server timezone to be honored by the MariaDB JDBC driver.
|
||||
*/
|
||||
@Test
|
||||
@ForPlatform({Platform.MARIADB})
|
||||
public void mariadb_simple_history() {
|
||||
void mariadb_simple_history() {
|
||||
|
||||
Timestamp t0 = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp t0 = currentDbSystemTime();
|
||||
littleSleep(50);
|
||||
|
||||
User user = new User();
|
||||
@@ -35,19 +39,19 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
user.setEmail("one@email.com");
|
||||
user.setPasswordHash("someHash");
|
||||
DB.save(user);
|
||||
Timestamp t1 = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp t1 = currentDbSystemTime();
|
||||
|
||||
littleSleep(100);
|
||||
user.setName("NotJim");
|
||||
user.save();
|
||||
Timestamp t2 = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp t2 = currentDbSystemTime();
|
||||
|
||||
littleSleep(100);
|
||||
user.setName("NotJimV2");
|
||||
user.setEmail("two@email.com");
|
||||
user.save();
|
||||
littleSleep(50);
|
||||
Timestamp t3 = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp t3 = currentDbSystemTime();
|
||||
|
||||
List<Version<User>> versions = DB.find(User.class).setId(user.getId()).findVersionsBetween(t0, t3);
|
||||
assertThat(versions).hasSize(3);
|
||||
|
||||
@@ -59,7 +59,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
*
|
||||
* @author Roland Praml, FOCONIS AG
|
||||
*/
|
||||
public class SqlQueryCancelTest extends BaseTestCase {
|
||||
class SqlQueryCancelTest extends BaseTestCase {
|
||||
|
||||
private final int timing = 20;
|
||||
|
||||
@@ -191,17 +191,13 @@ public class SqlQueryCancelTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cancelOrmDtoDuringIterate() {
|
||||
void cancelOrmDtoDuringIterate() {
|
||||
DtoQuery<EBasicDto> query = DB.find(EBasic.class).select("id,status").asDto(EBasicDto.class);
|
||||
|
||||
QueryIterator<EBasicDto> iter = query.findIterate();
|
||||
assertThat(iter.hasNext()).isTrue();
|
||||
query.cancel();
|
||||
if (isMariaDB()) {
|
||||
assertThrows(PersistenceException.class, iter::next);
|
||||
} else {
|
||||
assertThat(iter.next()).isNotNull();
|
||||
}
|
||||
assertThat(iter.next()).isNotNull();
|
||||
|
||||
// We might have 100 entities in a buffer. So we must iterate through all.
|
||||
assertThatThrownBy(() -> {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.UUID;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
|
||||
private String sql = "insert into uuone (id, name, version) values (?,?,?)";
|
||||
|
||||
@@ -63,7 +63,7 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void duplicateKey_inBatch() {
|
||||
void duplicateKey_inBatch() {
|
||||
UUID id = UUID.randomUUID();
|
||||
assertThrows(DuplicateKeyException.class, () -> {
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
@@ -85,7 +85,7 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void duplicateKey_executeBatch() {
|
||||
void duplicateKey_executeBatch() {
|
||||
UUID id = UUID.randomUUID();
|
||||
assertThrows(DuplicateKeyException.class, () -> {
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
|
||||
Reference in New Issue
Block a user