mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-12-01 15:37:14 +00:00
#1340 - Split SQL Server Platform into SqlServer16 and SqlServer17 (where 2017 which uses UTF8 types nvarchar etc and prefers Sequences).
test changes
This commit is contained in:
1 parent
8e0d2f8749
commit
f840cfc2ae
17 files changed
+260
-38
No files matched your search
@@ -6,20 +6,19 @@ import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServerPlatform;
|
||||
|
||||
import org.junit.*;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* This is the Migrationscript generator. It generates 3 migrationscript for the models
|
||||
@@ -57,7 +56,7 @@ public class DbMigrationGenerateTest {
|
||||
migration.addPlatform(Platform.SQLITE, "sqlite");
|
||||
|
||||
// we need sequence here, so that migration will work properly
|
||||
DatabasePlatform sqlServer = new SqlServerPlatform();
|
||||
DatabasePlatform sqlServer = new SqlServer17Platform();
|
||||
sqlServer.getDbIdentity().setIdType(IdType.SEQUENCE);
|
||||
migration.addDatabasePlatform(sqlServer, "sqlserver");
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServerPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||
import io.ebeaninternal.dbmigration.model.CurrentModel;
|
||||
@@ -34,7 +34,7 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
private DdlHandler sqlserverHandler() {
|
||||
return handler(new SqlServerPlatform());
|
||||
return handler(new SqlServer17Platform());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,7 +46,7 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
|
||||
write = new DdlWrite();
|
||||
sqlserverHandler().generate(write, Helper.getAddColumn());
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add added_to_foo varchar(20);\n\n");
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add added_to_foo nvarchar(20);\n\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServerPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||
import io.ebeaninternal.dbmigration.migration.IdentityType;
|
||||
import io.ebeaninternal.server.core.PlatformDdlBuilder;
|
||||
@@ -23,7 +23,7 @@ public class PlatformDdl_AlterColumnTest {
|
||||
private PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform());
|
||||
private PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform());
|
||||
private PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform());
|
||||
private PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServerPlatform());
|
||||
private PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform());
|
||||
|
||||
{
|
||||
ServerConfig serverConfig = Ebean.getDefaultServer().getPluginApi().getServerConfig();
|
||||
@@ -76,7 +76,7 @@ public class PlatformDdl_AlterColumnTest {
|
||||
assertEquals("alter table mytab modify acol varchar(5) not null", sql);
|
||||
|
||||
sql = sqlServerDdl.alterColumnBaseAttributes(alterColumn);
|
||||
assertEquals("alter table mytab alter column acol varchar(5) not null", sql);
|
||||
assertEquals("alter table mytab alter column acol nvarchar(5) not null", sql);
|
||||
|
||||
alterColumn.setNotnull(Boolean.FALSE);
|
||||
sql = mysqlDdl.alterColumnBaseAttributes(alterColumn);
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServerPlatform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
|
||||
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
|
||||
import io.ebeaninternal.server.core.PlatformDdlBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PlatformDdl_dropUniqueConstraintTest {
|
||||
private PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform());
|
||||
private PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform());
|
||||
private PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform());
|
||||
private PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServerPlatform());
|
||||
private PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform());
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
@@ -3,12 +3,14 @@ package io.ebeaninternal.extraddl.model;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ExtraDdlXmlReaderTest {
|
||||
|
||||
@Test
|
||||
public void read() throws Exception {
|
||||
public void read(){
|
||||
|
||||
ExtraDdl read = ExtraDdlXmlReader.read("/extra-ddl.xml");
|
||||
assertNotNull(read);
|
||||
@@ -44,4 +46,37 @@ public class ExtraDdlXmlReaderTest {
|
||||
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"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user