#1045 - MySql - DbMigration generate wrong comment syntax - should be alter table comment = syntax

This commit is contained in:
rob bygrave
2017-06-24 11:23:21 +12:00
parent 4b2481d3ea
commit cebd3f92a4
2 changed files with 25 additions and 0 deletions
@@ -101,4 +101,11 @@ public class MySqlDdl extends PlatformDdl {
apply.append(" comment='").append(tableComment).append("'");
}
/**
* Add table comment as a separate statement (from the create table statement).
*/
@Override
public void addTableComment(DdlBuffer apply, String tableName, String tableComment) throws IOException {
apply.append(String.format("alter table %s comment = '%s'", tableName, tableComment)).endOfStatement();
}
}
@@ -3,6 +3,7 @@ package io.ebean.dbmigration.ddlgeneration.platform;
import io.ebean.config.ServerConfig;
import io.ebean.config.dbplatform.h2.H2Platform;
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import io.ebean.dbmigration.ddlgeneration.DdlWrite;
import io.ebean.dbmigration.ddlgeneration.Helper;
@@ -93,6 +94,23 @@ public class BaseTableDdlTest {
assertThat(ddl).contains("comment on table mytab is 'my comment'");
}
@Test
public void testAddTableComment_mysql() throws IOException {
BaseTableDdl ddlGen = new BaseTableDdl(serverConfig, new MySqlPlatform().getPlatformDdl());
DdlWrite write = new DdlWrite();
AddTableComment addTableComment = new AddTableComment();
addTableComment.setName("mytab");
addTableComment.setComment("my comment");
ddlGen.generate(write, addTableComment);
String ddl = write.apply().getBuffer();
assertThat(ddl).contains("alter table mytab comment = 'my comment'");
}
@Test
public void testGenerate() throws Exception {