Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Roland Praml committed 2022-03-16 14:04:20 +01:00
commit e252ff4932
147 files changed
+2859 -2074

No files matched your search

+2 -2
View File
@@ -147,7 +147,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.2</version>
<version>42.3.3</version>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
@@ -233,7 +233,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<version>1.1</version>
<scope>test</scope>
</dependency>
@@ -10,8 +10,6 @@ import org.slf4j.LoggerFactory;
import java.util.Properties;
import javax.sql.DataSource;
/**
* Automatically configure ServerConfig for testing purposes.
* <p>
@@ -5,7 +5,6 @@ import io.ebean.datasource.DataSourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
import java.util.Properties;
/**
@@ -195,6 +195,14 @@ public abstract class BaseTestCase {
return Platform.DB2 == platform();
}
public boolean isSqLite() {
return Platform.SQLITE == platform();
}
public boolean isClickHouse() {
return Platform.CLICKHOUSE == platform();
}
public boolean platformDistinctOn() {
return isPostgresCompatible();
}
@@ -9,7 +9,6 @@ import org.tests.model.basic.ResetBasicData;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.*;
@@ -11,6 +11,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
@@ -32,10 +33,18 @@ public class DbMigrationDropHistoryTest {
main(null);
}
@Test
public void lastVersion_no_v_Prefix() {
File d = new File("src/test/resources/migrationtest-history/dbmigration");
assertThat(LastMigration.lastVersion(d, null)).isEqualTo("1.2");
}
public static void main(String[] args) throws IOException {
logger.info("start");
// First, we clean up the output-directory
Files.walk(Paths.get("src/test/resources/migrationtest-history"))
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
DefaultDbMigration migration = new DefaultDbMigration();
// We use src/test/resources as output directory (so we see in GIT if files will change)
@@ -1,7 +1,8 @@
package io.ebeaninternal.dbmigration;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -15,10 +16,20 @@ import java.nio.file.Paths;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* This is the Migrationscript generator. It generates 3 migrationscript for the models
* This is the Migrationscript generator. It will generate migrationscripts for all platforms.
* It uses the packages 'misc.migration'
* <ul>
* <li><code>misc.migration.v1_0</code> Initial package.
* <li><code>misc.migration.v1_1</code> modified v1_0 - every migration change, that ebean supports should be done here.
* <li><code>misc.migration.v1_2</code> This is (nearly) the same as v1_0 and simulates every migration change in the other way
* </ul>
*
* Changes in the migration scripts should be committed after they are reviewed (changes may be legitime or show, that something is broken).
* The {@link DbMigrationTest} will execute the generated scripts for various platforms.
* @author Roland Praml, FOCONIS AG
*
*/
@@ -38,46 +49,99 @@ public class DbMigrationGenerateTest {
public static void run(String pathToResources) throws IOException {
logger.info("start current directory: " + new File(".").getAbsolutePath());
// First, we clean up the output-directory
Files.walk(Paths.get(pathToResources, "migrationtest"))
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
DefaultDbMigration migration = new DefaultDbMigration();
migration.setIncludeIndex(true);
// We use src/test/resources as output directory (so we see in GIT if files will change)
migration.setPathToResources(pathToResources);
migration.addPlatform(Platform.CLICKHOUSE);
migration.addPlatform(Platform.COCKROACH);
// for platforms like DB2-LUW, we specify the exact platform in the migration path
// see https://github.com/ebean-orm/ebean-migration/issues/102
migration.addPlatform(Platform.DB2LUW, "db2luw");
migration.addPlatform(Platform.DB2FORI, "db2fori");
migration.addPlatform(Platform.DB2ZOS, "db2zos");
migration.addPlatform(Platform.DB2, "db2legacy");
migration.addPlatform(Platform.GENERIC);
migration.addPlatform(Platform.H2);
migration.addPlatform(Platform.HANA);
migration.addPlatform(Platform.HSQLDB);
migration.addPlatform(Platform.MARIADB);
migration.addPlatform(Platform.MARIADB, "mariadb-noprocs");
migration.addPlatform(Platform.MYSQL);
migration.addPlatform(Platform.MYSQL55, "mysql55");
migration.addPlatform(Platform.NUODB);
migration.addPlatform(Platform.ORACLE);
migration.addPlatform(Platform.ORACLE11, "oracle11"); // uses sequences
migration.addPlatform(Platform.POSTGRES);
migration.addPlatform(Platform.POSTGRES9, "postgres9"); // different DDL as base!
migration.addPlatform(Platform.SQLANYWHERE);
migration.addPlatform(Platform.SQLITE);
migration.addPlatform(Platform.SQLSERVER16, "sqlserver16");
migration.addPlatform(Platform.SQLSERVER17, "sqlserver17");
migration.addPlatform(Platform.YUGABYTE);
DatabaseConfig config = new DatabaseConfig();
config.setName("migrationtest");
config.loadFromProperties();
config.setRegister(false);
config.setDefaultServer(false);
config.getProperties().put("ebean.migrationtest.migration.pathToResources", pathToResources);
config.setPackages(Arrays.asList("misc.migration.v1_0"));
config.getProperties().put("ebean.hana.generateUniqueDdl", "true"); // need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
// First, we clean up the output-directory
Files.walk(Paths.get(pathToResources, "migrationtest"))
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
DatabaseFactory.create(config).shutdown();
config.setPackages(Arrays.asList("misc.migration.v1_0"));
Database server = DatabaseFactory.create(config);
migration.setServer(server);
// then we generate migration scripts for v1_0
assertThat(DbMigrationPlugin.getLastMigration()).isEqualTo("1.0__initial");
assertThat(DbMigrationPlugin.getLastInit()).isEqualTo("1.0__initial");
assertThat(migration.generateMigration()).isEqualTo("1.0__initial");
// and we check repeatative calls
DatabaseFactory.create(config).shutdown();
assertThat(DbMigrationPlugin.getLastMigration()).isNull();
assertThat(DbMigrationPlugin.getLastInit()).isNull();
assertThat(migration.generateMigration()).isNull();
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.v1_1"));
DatabaseFactory.create(config).shutdown();
assertThat(DbMigrationPlugin.getLastMigration()).isEqualTo("1.1,1.2__dropsFor_1.1");
assertThat(DbMigrationPlugin.getLastInit()).isEqualTo("1.2");
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.1");
assertThat(migration.generateMigration()).isNull(); // subsequent call
// subsequent call
DatabaseFactory.create(config).shutdown();
assertThat(DbMigrationPlugin.getLastMigration()).isNull();
assertThat(DbMigrationPlugin.getLastInit()).isNull();
// and now for v1_2
System.setProperty("ddl.migration.pendingDropsFor", "1.1");
assertThat(migration.generateMigration()).isEqualTo("1.2__dropsFor_1.1");
assertThatThrownBy(()->migration.generateMigration())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("No 'pendingDrops'"); // subsequent call
System.clearProperty("ddl.migration.pendingDropsFor");
assertThat(migration.generateMigration()).isNull(); // subsequent call
// and now for v1_2 with
config.setPackages(Arrays.asList("misc.migration.v1_2"));
DatabaseFactory.create(config).shutdown();
assertThat(DbMigrationPlugin.getLastMigration()).isEqualTo("1.3,1.4__dropsFor_1.3");
assertThat(DbMigrationPlugin.getLastInit()).isEqualTo("1.4");
server.shutdown();
server = DatabaseFactory.create(config);
migration.setServer(server);
assertThat(migration.generateMigration()).isEqualTo("1.3");
assertThat(migration.generateMigration()).isNull(); // subsequent call
System.setProperty("ddl.migration.pendingDropsFor", "1.3");
assertThat(migration.generateMigration()).isEqualTo("1.4__dropsFor_1.3");
assertThatThrownBy(migration::generateMigration)
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("No 'pendingDrops'"); // subsequent call
System.clearProperty("ddl.migration.pendingDropsFor");
assertThat(migration.generateMigration()).isNull(); // subsequent call
server.shutdown();
logger.info("end");
}
@@ -9,7 +9,6 @@ class BasicProfileLocationTest {
@Test
void obtain() {
DProfileLocation loc = new DTimedProfileLocation(12, "foo", MetricFactory.get().createTimedMetric("junk"));
String javaVersion = System.getProperty("java.version");
@@ -18,7 +17,7 @@ class BasicProfileLocationTest {
assertThat(loc.fullLocation()).endsWith("invoke0(Native Method:12)");
assertThat(loc.location()).isEqualTo("sun.reflect.NativeMethodAccessorImpl.invoke0");
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
} else if (javaVersion.startsWith("18")){
} else if (javaVersion.startsWith("18") || javaVersion.startsWith("19")){
assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)");
assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke");
assertThat(loc.label()).isEqualTo("DirectMethodHandleAccessor.invoke");
@@ -31,7 +30,6 @@ class BasicProfileLocationTest {
@Test
void basic_trimPackage() {
BasicProfileLocation loc = new BasicProfileLocation("com.foo.Bar.all");
assertThat(loc.obtain()).isFalse();
assertThat(loc.fullLocation()).isEqualTo("com.foo.Bar.all");
@@ -41,7 +39,6 @@ class BasicProfileLocationTest {
@Test
void basic_trimSinglePackage() {
BasicProfileLocation loc = new BasicProfileLocation("foo.Bar.all");
assertThat(loc.obtain()).isFalse();
assertThat(loc.fullLocation()).isEqualTo("foo.Bar.all");
@@ -1,7 +1,6 @@
package io.ebeaninternal.server.type;
import static java.lang.String.format;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import java.sql.Date;
import java.sql.Timestamp;
@@ -18,13 +17,11 @@ import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import javax.sql.DataSource;
import org.assertj.core.api.SoftAssertions;
import org.joda.time.DateTimeZone;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -15,7 +15,6 @@ import org.tests.model.ivo.converter.MoneyTypeConverter;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,7 +47,7 @@ public class EBasic {
@Size(max=127)
String description;
@Lob
@Column(columnDefinition = "db2;blob(64M);")
File descriptionFile;
@@ -23,4 +23,20 @@ public class EHistory {
@DbMigration(platforms = Platform.POSTGRES,
preAlter = "alter table ${table} alter column ${column} TYPE bigint USING (${column}::integer)")
Long testString;
public Long getTestString() {
return testString;
}
public void setTestString(Long testString) {
this.testString = testString;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
@@ -41,4 +41,45 @@ public class EHistory2 {
@Size(max = 20)
String newColumn;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTestString() {
return testString;
}
public void setTestString(String testString) {
this.testString = testString;
}
public String getTestString2() {
return testString2;
}
public void setTestString2(String testString2) {
this.testString2 = testString2;
}
public String getTestString3() {
return testString3;
}
public void setTestString3(String testString3) {
this.testString3 = testString3;
}
public String getNewColumn() {
return newColumn;
}
public void setNewColumn(String newColumn) {
this.newColumn = newColumn;
}
}
@@ -8,13 +8,14 @@ import org.junit.jupiter.api.Test;
import org.tests.model.basic.EBasicClobNoVer;
import java.util.List;
import java.util.Random;
import static org.assertj.core.api.Assertions.assertThat;
public class TestBasicClobNoVer extends BaseTestCase {
class TestBasicClobNoVer extends BaseTestCase {
@Test
public void test() {
void test() {
EBasicClobNoVer entity = new EBasicClobNoVer();
entity.setName("test");
@@ -65,4 +66,36 @@ public class TestBasicClobNoVer extends BaseTestCase {
assertThat(entity.getDescription()).isEqualTo("modified");
}
@Test
void refresh_withSoftDelete() {
EBasicClobNoVer bean = new EBasicClobNoVer();
bean.setDescription("hello");
DB.save(bean);
DB.refresh(bean);
LoggedSql.start();
bean.children().forEach(System.out::println);
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains(" and t0.deleted =");
}
@Test
void largeValueInsert() {
EBasicClobNoVer bean = new EBasicClobNoVer();
bean.setDescription(largeContent());
DB.save(bean);
}
private String largeContent() {
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1048577; i++) {
sb.append((char) (random.nextInt(26) + 'a'));
}
return sb.toString();
}
}
@@ -1,7 +1,6 @@
package org.tests.inheritance.bothsides;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
@Entity
public class Target1 extends TargetBase {
@@ -3,6 +3,9 @@ package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import java.util.ArrayList;
import java.util.List;
@Entity
public class EBasicClobNoVer {
@@ -18,6 +21,9 @@ public class EBasicClobNoVer {
@Lob
private String description;
@OneToMany
private List<EBasicClobNoVerChild> children = new ArrayList<>();
public void setId(Long id) {
this.id = id;
}
@@ -41,4 +47,13 @@ public class EBasicClobNoVer {
public String getDescription() {
return description;
}
public List<EBasicClobNoVerChild> children() {
return children;
}
public EBasicClobNoVer children(List<EBasicClobNoVerChild> children) {
this.children = children;
return this;
}
}
@@ -0,0 +1,49 @@
package org.tests.model.basic;
import io.ebean.annotation.SoftDelete;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
@Entity
public class EBasicClobNoVerChild {
@Id
private Long id;
@ManyToOne
private final EBasicClobNoVer parent;
private final String child;
@SoftDelete
private boolean deleted;
public EBasicClobNoVerChild(EBasicClobNoVer parent, String child) {
this.parent = parent;
this.child = child;
}
public Long id() {
return id;
}
public EBasicClobNoVerChild id(Long id) {
this.id = id;
return this;
}
public String child() {
return child;
}
public boolean deleted() {
return deleted;
}
public EBasicClobNoVerChild deleted(boolean deleted) {
this.deleted = deleted;
return this;
}
}
@@ -16,8 +16,6 @@ import javax.annotation.Nullable;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.joda.time.DateTime;
@Entity
public class MDateTime {
@@ -28,6 +28,7 @@ public class TWithPreInsert implements TWithPreInsertCommon {
*/
transient int requestCascadeState;
@Override
public Integer getId() {
return id;
}
@@ -36,18 +37,22 @@ public class TWithPreInsert implements TWithPreInsertCommon {
this.id = id;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getTitle() {
return title;
}
@Override
public void setTitle(String title) {
this.title = title;
}
@@ -60,6 +65,7 @@ public class TWithPreInsert implements TWithPreInsertCommon {
return requestCascadeState;
}
@Override
public void requestCascadeState(int requestCascadeState) {
this.requestCascadeState = requestCascadeState;
}
@@ -24,6 +24,7 @@ public class TWithPreInsertChild implements TWithPreInsertCommon {
this.name = name;
}
@Override
public Integer getId() {
return id;
}
@@ -32,18 +33,22 @@ public class TWithPreInsertChild implements TWithPreInsertCommon {
this.id = id;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getTitle() {
return title;
}
@Override
public void setTitle(String title) {
this.title = title;
}
@@ -52,6 +57,7 @@ public class TWithPreInsertChild implements TWithPreInsertCommon {
return requestCascadeState;
}
@Override
public void requestCascadeState(int requestCascadeState) {
this.requestCascadeState = requestCascadeState;
}
@@ -70,7 +70,7 @@ public class TestHistoryExclude extends BaseTestCase {
linkFound.getDocs().size();
}
@IgnorePlatform({Platform.ORACLE, Platform.DB2, Platform.COCKROACH})
@IgnorePlatform({Platform.ORACLE, 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, Platform.COCKROACH})
@IgnorePlatform({Platform.ORACLE, 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, Platform.COCKROACH})
@IgnorePlatform({Platform.ORACLE, Platform.COCKROACH})
@Test
public void test() throws InterruptedException {
@@ -3,24 +3,22 @@ package org.tests.model.lazywithcache;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Transaction;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.List;
/**
* Test with bean cache and lazy loaded property.
*
* @author Noemi Szemenyei, FOCONIS AG
*
*/
public class TestWithCacheAndLazyLoad extends BaseTestCase{
class TestWithCacheAndLazyLoad extends BaseTestCase {
@Test
public void testGetters() {
void testGetters() {
ChildWithCache child = new ChildWithCache();
child.setId(1L);
@@ -52,19 +50,19 @@ public class TestWithCacheAndLazyLoad extends BaseTestCase{
assertThat(temp.getAddress()).isEqualTo("Address");
assertThat(temp.getName()).isEqualTo("Child With Cache");
}
@Test
public void testBatch() throws Exception {
void testBatch() {
for (int i = 0; i < 2; i++) {
ChildWithCache child = new ChildWithCache();
child.setId(1000L+i);
child.setName("Child With Cache "+ i);
child.setId(1000L + i);
child.setName("Child With Cache " + i);
child.setAddress("Address");
DB.save(child);
ParentA parentA = new ParentA();
parentA.setId(1000L+i);
parentA.setId(1000L + i);
parentA.setName("Parent A");
parentA.setChild(child);
DB.save(parentA);
@@ -72,7 +70,7 @@ public class TestWithCacheAndLazyLoad extends BaseTestCase{
// 0. load cache
ParentA temp = DB.find(ParentA.class, 1000L);
temp.getChild().getName();
try (Transaction txn = DB.beginTransaction()) {
// 1. FindList
List<ParentA> list = DB.find(ParentA.class).where().ge("id", 1000L).orderBy("id").findList();
@@ -5,6 +5,7 @@ import io.ebean.DB;
import io.ebean.SqlRow;
import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -142,13 +143,16 @@ public class TestNoFk extends BaseTestCase {
assertTrue(ownerEbi.isReference());
assertTrue(ownerEbi.isPartial());
assertTrue(ownerEbi.isLazyLoadFailure());
}
@Test
public void testEagerLoadFile() {
LoggedSql.start();
List<EFileNoFk> files = DB.find(EFileNoFk.class).fetch("owner").findList();
assertThat(files).hasSize(2);
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("select t0.file_name, t0.owner_user_id, t0.owner_soft_del_user_id, t1.user_id, t1.user_name from efile_no_fk t0 left join euser_no_fk t1 on t1.user_id = t0.owner_user_id");
EFileNoFk file1 = files.get(0);
EFileNoFk file2 = files.get(1);
@@ -175,7 +179,6 @@ public class TestNoFk extends BaseTestCase {
assertTrue(ownerEbi.isReference());
assertTrue(ownerEbi.isPartial());
assertTrue(ownerEbi.isLazyLoadFailure());
}
@Test
@@ -259,8 +262,14 @@ public class TestNoFk extends BaseTestCase {
@Test
public void testEagerLoadFileSoftDel() {
LoggedSql.start();
List<EFileNoFk> files = DB.find(EFileNoFk.class).fetch("ownerSoftDel").findList();
assertThat(files).hasSize(2);
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
if (isH2() || isPostgres()) {
assertThat(sql.get(0)).contains("select t0.file_name, t0.owner_user_id, t0.owner_soft_del_user_id, t1.user_id, t1.user_name, t1.user_id is null from efile_no_fk t0 left join euser_no_fk_soft_del t1 on t1.user_id = t0.owner_soft_del_user_id");
}
EFileNoFk file1 = files.get(0);
EFileNoFk file2 = files.get(1);
@@ -14,7 +14,6 @@ class TestQueryMultiJoinFetchPath extends BaseTestCase {
@Test
void test() {
HCustomer c1 = new HCustomer("c1", "c1");
DB.save(c1);
@@ -60,9 +59,9 @@ class TestQueryMultiJoinFetchPath extends BaseTestCase {
assertThat(accesses).hasSize(2);
if (isH2()) {
assertThat(query.getGeneratedSql()).isEqualTo("select t0.dtype, t0.id, t0.accessor_id, t0.principal_id, t2.dtype, t0.access_account_number, t0.accessor_id, t2.dtype, t0.access_account_number, t1.cid, t1.name, t2.dtype, t2.account_number from haccess t0 left join hcustomer t1 on t1.cid = t0.accessor_id left join haccount t2 on t2.account_number = t0.access_account_number and t2.dtype = 'B' left join hcustomer t3 on t3.cid = t0.principal_id where t1.status = ? and t3.status = ? and t0.id in (?,?,?,?,?)");
assertThat(query.getGeneratedSql()).isEqualTo("select t0.dtype, t0.id, t0.accessor_id, t0.principal_id, t2.dtype, t0.access_account_number, t1.cid, t1.name, t2.dtype, t2.account_number from haccess t0 left join hcustomer t1 on t1.cid = t0.accessor_id left join haccount t2 on t2.account_number = t0.access_account_number and t2.dtype = 'B' left join hcustomer t3 on t3.cid = t0.principal_id where t1.status = ? and t3.status = ? and t0.id in (?,?,?,?,?)");
} else {
assertThat(query.getGeneratedSql()).contains("select t0.dtype, t0.id, t0.accessor_id, t0.principal_id, t2.dtype, t0.access_account_number, t0.accessor_id, t2.dtype, t0.access_account_number, t1.cid, t1.name, t2.dtype, t2.account_number from haccess t0 left join hcustomer t1 on t1.cid = t0.accessor_id left join haccount t2 on t2.account_number = t0.access_account_number and t2.dtype = 'B' left join hcustomer t3 on t3.cid = t0.principal_id where t1.status = ? and t3.status = ? and t0.id ");
assertThat(query.getGeneratedSql()).contains("select t0.dtype, t0.id, t0.accessor_id, t0.principal_id, t2.dtype, t0.access_account_number, t1.cid, t1.name, t2.dtype, t2.account_number from haccess t0 left join hcustomer t1 on t1.cid = t0.accessor_id left join haccount t2 on t2.account_number = t0.access_account_number and t2.dtype = 'B' left join hcustomer t3 on t3.cid = t0.principal_id where t1.status = ? and t3.status = ? and t0.id ");
}
}
@@ -3,6 +3,8 @@ package org.tests.query.finder;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Transaction;
import io.ebean.annotation.IgnorePlatform;
import io.ebean.annotation.Platform;
import io.ebean.meta.*;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Test;
@@ -163,6 +165,7 @@ public class TestCustomerFinder extends BaseTestCase {
}
@Test
@IgnorePlatform(Platform.DB2) // no query plans yet, for DB2
public void test_finders_queryPlans() {
ResetBasicData.reset();
@@ -13,7 +13,6 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
public class TestRawSqlNamedParams extends BaseTestCase {
@@ -9,7 +9,6 @@ import io.ebean.util.IOUtils;
import org.junit.jupiter.api.Test;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -149,7 +149,7 @@ datasource.yugabyte.username=unit
datasource.yugabyte.password=test
datasource.yugabyte.url=jdbc:postgresql://localhost:6433/unit?sslmode=disable
datasource.oracle.username=test_ebean
datasource.oracle.username=test_eb
datasource.oracle.password=test
datasource.oracle.url=jdbc:oracle:thin:@localhost:1521:XE
#datasource.oracle.driver=oracle.jdbc.driver.OracleDriver
@@ -221,15 +221,17 @@ dbmigration.platform.mariadb.useMigrationStoredProcedures=true
dbmigration.platform.mysql.useMigrationStoredProcedures=true
# need to generate unique statements to prevent them from being filtered out as duplicates by the DdlRunner
ebean.hana.generateUniqueDdl=true
ebean.migrationtest.migration.strict=true
# enable stored procedures f
dbmigration.platform.mariadb.useMigrationStoredProcedures=true
dbmigration.platform.mysql.useMigrationStoredProcedures=true
dbmigration.platform.mysql55.useMigrationStoredProcedures=true
# parameters for migration test
datasource.migrationtest-history.username=SA
datasource.migrationtest-history.password=SA
datasource.migrationtest-history.url=jdbc:h2:mem:migration
ebean.migrationtest-history.applyPrefix=V
ebean.migrationtest-history.ddl.generate=false
ebean.migrationtest-history.ddl.run=false
ebean.migrationtest-history.ddl.header=-- Migrationscripts for ebean unittest DbMigrationDropHistoryTest
@@ -1,4 +1,5 @@
ebean.test.platform=cockroach
ebean.test.dbName=unit
datasource.default=cockroach
#ebean.test.cockroach.version=v21.2.6
@@ -0,0 +1,6 @@
# Note: You need a running docker container. See howto-test.md for details
datasource.default=hana
datasource.hana.username=SYSTEM
datasource.hana.password=VeryVerySecret#1234
datasource.hana.url=jdbc:sap://localhost:39041/