mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Split Postgres platform into Postgres10 & Postgres9 (DDL - generated by default as identity) (#1921)
* Split Postgres platform into Postgres10 & Postgres9 - Use "generated by default as identity" for Postgres10 identity columns * Add postgres9 migrationtest resources * Set default back to h2 * Add postgres10 migration test resources
This commit is contained in:
@@ -199,7 +199,7 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
public boolean isPostgres() {
|
||||
return Platform.POSTGRES == platform();
|
||||
return Platform.POSTGRES == platform().base();
|
||||
}
|
||||
|
||||
public boolean isMySql() {
|
||||
|
||||
@@ -37,13 +37,9 @@ public class ConditionalTestRunner extends BlockJUnit4ClassRunner {
|
||||
|
||||
}
|
||||
private boolean platformMath(Platform[] platforms) {
|
||||
Platform current = DB.getDefault().getPluginApi().getDatabasePlatform().getPlatform();
|
||||
for (Platform p : platforms) {
|
||||
if (p.equals(current)) {
|
||||
return true;
|
||||
}
|
||||
if (p == Platform.SQLSERVER && current == Platform.SQLSERVER17) {
|
||||
// treat SQLSERVER as SQLSERVER17 in testing
|
||||
Platform basePlatform = DB.getDefault().getPluginApi().getDatabasePlatform().getPlatform().base();
|
||||
for (Platform platform : platforms) {
|
||||
if (platform.equals(basePlatform)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class ServerConfigSqlServerTest {
|
||||
|
||||
@Ignore
|
||||
@ForPlatform({Platform.SQLSERVER, Platform.SQLSERVER17, Platform.SQLSERVER16})
|
||||
@ForPlatform({Platform.SQLSERVER})
|
||||
@Test(expected = PersistenceException.class)
|
||||
public void need_explicitPlatform() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ServerConfigSqlServerTest {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@ForPlatform({Platform.SQLSERVER, Platform.SQLSERVER17, Platform.SQLSERVER16})
|
||||
@ForPlatform({Platform.SQLSERVER})
|
||||
@Test
|
||||
public void explicit_17() {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ServerConfigSqlServerTest {
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@ForPlatform({Platform.SQLSERVER, Platform.SQLSERVER17, Platform.SQLSERVER16})
|
||||
@ForPlatform({Platform.SQLSERVER})
|
||||
@Test
|
||||
public void explicit_16() {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class DatabasePlatformTest {
|
||||
|
||||
@Test
|
||||
public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() throws Exception {
|
||||
public void convertQuotedIdentifiers_when_allQuotedIdentifier_sqlServer() {
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
config.setAllQuotedIdentifiers(true);
|
||||
@@ -29,7 +29,7 @@ public class DatabasePlatformTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertQuotedIdentifiers() throws Exception {
|
||||
public void convertQuotedIdentifiers() {
|
||||
|
||||
ServerConfig config = new ServerConfig();
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DatabasePlatformTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultTypesForDecimalAndVarchar() throws Exception {
|
||||
public void defaultTypesForDecimalAndVarchar() {
|
||||
|
||||
DatabasePlatform dbPlatform = new DatabasePlatform();
|
||||
assertEquals(defaultDecimalDefn(dbPlatform), "decimal(38)");
|
||||
@@ -54,7 +54,7 @@ public class DatabasePlatformTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configure_customType() throws Exception {
|
||||
public void configure_customType() {
|
||||
|
||||
PlatformConfig config = new PlatformConfig();
|
||||
config.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PlatformMatchTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void match() {
|
||||
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "h2"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "mysql,h2"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "mysql,h2,"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "mysql , h2 ,"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "mysql , h2, oracle"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.H2, "mysql , h2, oracle"));
|
||||
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER, "sqlserver"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER17, "sqlserver"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER16, "sqlserver"));
|
||||
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.POSTGRES, "postgres"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.POSTGRES9, "postgres"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.POSTGRES10, "postgres"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void match_sqlserver17_matchAlsoToGenericName() {
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER17, "sqlserver"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER17, "sqlserver17"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform_sqlserver16_matchAlsoToGenericName() {
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER16, "sqlserver"));
|
||||
assertTrue(PlatformMatch.matchPlatform(Platform.SQLSERVER16, "sqlserver16"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform_sqlserver_nonMatch() {
|
||||
assertFalse(PlatformMatch.matchPlatform(Platform.SQLSERVER16, "sqlserver17"));
|
||||
assertFalse(PlatformMatch.matchPlatform(Platform.SQLSERVER17, "sqlserver16"));
|
||||
assertFalse(PlatformMatch.matchPlatform(Platform.SQLSERVER, "sqlserver16"));
|
||||
assertFalse(PlatformMatch.matchPlatform(Platform.SQLSERVER, "sqlserver17"));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.extraddl.model;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -19,7 +20,7 @@ public class ExtraDdlXmlReaderTest {
|
||||
@Test
|
||||
public void buildExtra_when_h2() {
|
||||
|
||||
String ddl = ExtraDdlXmlReader.buildExtra("h2", false);
|
||||
String ddl = ExtraDdlXmlReader.buildExtra(Platform.H2, false);
|
||||
|
||||
assertThat(ddl).contains("create or replace view order_agg_vw");
|
||||
assertThat(ddl).contains("-- h2 and postgres script");
|
||||
@@ -29,7 +30,7 @@ public class ExtraDdlXmlReaderTest {
|
||||
@Test
|
||||
public void buildExtra_when_oracle() {
|
||||
|
||||
String ddl = ExtraDdlXmlReader.buildExtra("oracle", false);
|
||||
String ddl = ExtraDdlXmlReader.buildExtra(Platform.ORACLE, false);
|
||||
|
||||
assertThat(ddl).contains("create or replace view order_agg_vw");
|
||||
assertThat(ddl).doesNotContain("-- h2 and postgres script");
|
||||
@@ -39,44 +40,11 @@ public class ExtraDdlXmlReaderTest {
|
||||
@Test
|
||||
public void buildExtra_when_mysql() {
|
||||
|
||||
String ddl = ExtraDdlXmlReader.buildExtra("mysql", false);
|
||||
String ddl = ExtraDdlXmlReader.buildExtra(Platform.MYSQL, false);
|
||||
|
||||
assertThat(ddl).contains("create or replace view order_agg_vw");
|
||||
assertThat(ddl).doesNotContain("-- h2 and postgres script");
|
||||
assertThat(ddl).doesNotContain(" -- oracle only script");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform() {
|
||||
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "h2"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "mysql,h2"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "mysql,h2,"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "mysql , h2 ,"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "mysql , h2, oracle"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("h2", "mysql , h2, oracle"));
|
||||
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("sqlserver17", "sqlserver17"));
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("sqlserver16", "sqlserver16"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform_sqlserver17_matchAlsoToGenericName() {
|
||||
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("sqlserver17", "sqlserver"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform_sqlserver16_matchAlsoToGenericName() {
|
||||
|
||||
assertTrue(ExtraDdlXmlReader.matchPlatform("sqlserver16", "sqlserver"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchPlatform_sqlserver_nonMatch() {
|
||||
|
||||
assertFalse(ExtraDdlXmlReader.matchPlatform("sqlserver16", "sqlserver17"));
|
||||
assertFalse(ExtraDdlXmlReader.matchPlatform("sqlserver17", "sqlserver16"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ public class DeployPropertyParserTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(value = {Platform.H2, Platform.POSTGRES})
|
||||
@ForPlatform({Platform.H2, Platform.POSTGRES})
|
||||
public void withQuote_when_match_h2() {
|
||||
assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}\"Name\" like ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(value = Platform.SQLSERVER)
|
||||
@ForPlatform(Platform.SQLSERVER)
|
||||
public void withQuote_when_match_sqlserver() {
|
||||
assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}[Name] like ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform(value = Platform.MYSQL)
|
||||
@ForPlatform(Platform.MYSQL)
|
||||
public void withQuote_when_match_mysql() {
|
||||
assertThat(withQuoteParser().parse("name like ?")).isEqualTo("${}`Name` like ?");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.PostgresConfig;
|
||||
import io.ebean.docker.commands.PostgresContainer;
|
||||
|
||||
public class StartPostgres9 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
PostgresConfig config = new PostgresConfig("9.6");
|
||||
config.setPort("9432");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
config.setContainerName("pg9");
|
||||
config.setExtensions("hstore,pgcrypto");
|
||||
|
||||
PostgresContainer container = new PostgresContainer(config);
|
||||
container.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -23,9 +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})
|
||||
public void testForUpdate() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
@@ -43,9 +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})
|
||||
public void testForUpdate_when_alreadyInPC() {
|
||||
|
||||
EBasic basic = new EBasic("test PC cache");
|
||||
@@ -79,9 +75,7 @@ public class TestQueryForUpdate extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform({
|
||||
Platform.H2, Platform.POSTGRES, Platform.SQLSERVER, Platform.ORACLE
|
||||
})
|
||||
@ForPlatform({Platform.H2, Platform.POSTGRES, Platform.SQLSERVER, Platform.ORACLE})
|
||||
public void testForUpdate_noWait_noMaxRows() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
@@ -103,9 +97,7 @@ public class TestQueryForUpdate extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForPlatform({
|
||||
Platform.H2, Platform.POSTGRES, Platform.SQLSERVER
|
||||
})
|
||||
@ForPlatform({Platform.H2, Platform.POSTGRES, Platform.SQLSERVER})
|
||||
public void testForUpdate_noWait() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Reference in New Issue
Block a user