mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Add testcase, that uses all kinds of reserved keywords
This commit is contained in:
1 parent
4077d906d1
commit
04d2a20945
93 files changed
+1129
-64
No files matched your search
@@ -6,6 +6,7 @@ import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.DbHistorySupport;
|
||||
import io.ebean.datasource.pool.ConnectionPool;
|
||||
import misc.migration.v1_0.ETable;
|
||||
import misc.migration.v1_1.EHistory;
|
||||
import misc.migration.v1_1.EHistory2;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -84,7 +85,10 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
"migtest_mtm_c_migtest_mtm_m",
|
||||
"migtest_mtm_m_migtest_mtm_c",
|
||||
"migtest_oto_child",
|
||||
"migtest_oto_master");
|
||||
"migtest_oto_master",
|
||||
"table",
|
||||
"\"table\"",
|
||||
"`table`");
|
||||
((ConnectionPool)server().dataSource()).offline();
|
||||
((ConnectionPool)server().dataSource()).online();
|
||||
|
||||
@@ -113,7 +117,7 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
|
||||
assertThat(server().execute(update)).isEqualTo(2);
|
||||
}
|
||||
|
||||
testReservedKeywords();
|
||||
createHistoryEntities();
|
||||
if (isOracle()) {
|
||||
// Oracle does not like to convert varchar to integer
|
||||
@@ -258,6 +262,32 @@ public class DbMigrationTest extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// do some history tests with V1.1 models
|
||||
private void testReservedKeywords() {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
config.setName(server().name());
|
||||
config.loadFromProperties(server().pluginApi().config().getProperties());
|
||||
config.setDataSource(server().dataSource());
|
||||
config.setReadOnlyDataSource(server().dataSource());
|
||||
config.setDdlGenerate(false);
|
||||
config.setDdlRun(false);
|
||||
config.setRegister(false);
|
||||
config.setPackages(Collections.singletonList("misc.migration.v1_0"));
|
||||
|
||||
Database tmpServer = DatabaseFactory.create(config);
|
||||
try {
|
||||
ETable table = new misc.migration.v1_0.ETable();
|
||||
table.setFrom("foo");
|
||||
table.setTo("bar");
|
||||
table.setIndex("id");
|
||||
tmpServer.save(table);
|
||||
table = tmpServer.find(ETable.class).where().eq("index", "id").findOne();
|
||||
assert table != null;
|
||||
} finally {
|
||||
tmpServer.shutdown(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void createHistoryEntities() {
|
||||
SqlUpdate update = server().sqlUpdate("insert into migtest_e_history (id, test_string) values (1, '42')");
|
||||
assertThat(server().execute(update)).isEqualTo(1);
|
||||
|
||||
Reference in new issue
Block a user