No effective change, tidy whitespace

This commit is contained in:
Rob Bygrave committed 2022-05-16 21:35:46 +12:00
1 parent 091c40867e
commit cc7f3d49a4
4 files changed
+5 -66

No files matched your search

@@ -29,7 +29,7 @@ public class BaseAlterTableWrite implements DdlAlterTable {
@Override @Override
public DdlBuffer endOfStatement() { public DdlBuffer endOfStatement() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
}; }
}; };
protected AlterCmd(String operation, String column) { protected AlterCmd(String operation, String column) {
@@ -82,9 +82,7 @@ public class BaseAlterTableWrite implements DdlAlterTable {
} }
private final String tableName; private final String tableName;
private final List<AlterCmd> cmds = new ArrayList<>();
private List<AlterCmd> cmds = new ArrayList<>();
private boolean historyHandled; private boolean historyHandled;
public BaseAlterTableWrite(String tableName, PlatformDdl platformDdl) { public BaseAlterTableWrite(String tableName, PlatformDdl platformDdl) {
@@ -102,10 +100,6 @@ public class BaseAlterTableWrite implements DdlAlterTable {
return cmd; return cmd;
} }
public AlterCmd newOperation(String operation, String column) {
return new AlterCmd(operation, column);
}
/** /**
* Adds a statement. The statement is prefixed with "alter table TABLENAME" and may be batched, if platform supports this. The * Adds a statement. The statement is prefixed with "alter table TABLENAME" and may be batched, if platform supports this. The
* returned StringBuilder can be used, to complete the statement * returned StringBuilder can be used, to complete the statement
@@ -256,8 +256,6 @@ public class BaseTableDdl implements TableDdl {
} }
} }
private String sequenceName(CreateTable createTable, List<Column> pk) { private String sequenceName(CreateTable createTable, List<Column> pk) {
return namingConvention.getSequenceName(createTable.getName(), pk.get(0).getName()); return namingConvention.getSequenceName(createTable.getName(), pk.get(0).getName());
} }
@@ -726,18 +724,15 @@ public class BaseTableDdl implements TableDdl {
} }
boolean alterCheckConstraint = hasValue(alterColumn.getCheckConstraint()); boolean alterCheckConstraint = hasValue(alterColumn.getCheckConstraint());
if (alterCheckConstraint) { if (alterCheckConstraint) {
// drop constraint before altering type etc // drop constraint before altering type etc
dropCheckConstraint(writer, alterColumn, alterColumn.getCheckConstraintName()); dropCheckConstraint(writer, alterColumn, alterColumn.getCheckConstraintName());
} }
if (typeChange(alterColumn) if (typeChange(alterColumn)
|| hasValue(alterColumn.getDefaultValue()) || hasValue(alterColumn.getDefaultValue())
|| alterColumn.isNotnull() != null) { || alterColumn.isNotnull() != null) {
alterColumn(writer, alterColumn); alterColumn(writer, alterColumn);
} }
if (alterCheckConstraint) { if (alterCheckConstraint) {
// add constraint last (after potential type change) // add constraint last (after potential type change)
addCheckConstraint(writer, alterColumn); addCheckConstraint(writer, alterColumn);
@@ -1,14 +1,11 @@
package io.ebeaninternal.dbmigration.ddlgeneration.platform; package io.ebeaninternal.dbmigration.ddlgeneration.platform;
public class DdlHelp { public class DdlHelp {
public static final String TABLESPACE_DEFAULT = "$TABLESPACE_DEFAULT"; public static final String TABLESPACE_DEFAULT = "$TABLESPACE_DEFAULT";
public static final String DROP_DEFAULT = "DROP DEFAULT"; public static final String DROP_DEFAULT = "DROP DEFAULT";
public static final String DROP_COMMENT = "DROP COMMENT"; public static final String DROP_COMMENT = "DROP COMMENT";
public static final String DROP_CONSTRAINT = "DROP CONSTRAINT"; public static final String DROP_CONSTRAINT = "DROP CONSTRAINT";
public static final String DROP_FOREIGN_KEY = "DROP FOREIGN KEY"; public static final String DROP_FOREIGN_KEY = "DROP FOREIGN KEY";
/** /**
@@ -29,39 +29,30 @@ public class PlatformDdl {
private static final Pattern CHECK_PATTERN = Pattern.compile("(.*?\\( *)([^ ]+)(.*)"); private static final Pattern CHECK_PATTERN = Pattern.compile("(.*?\\( *)([^ ]+)(.*)");
protected final DatabasePlatform platform; protected final DatabasePlatform platform;
protected PlatformHistoryDdl historyDdl = new NoHistorySupportDdl(); protected PlatformHistoryDdl historyDdl = new NoHistorySupportDdl();
/** /**
* Converter for logical/standard types to platform specific types. (eg. clob -> text) * Converter for logical/standard types to platform specific types. (eg. clob -> text)
*/ */
private final PlatformTypeConverter typeConverter; private final PlatformTypeConverter typeConverter;
/** /**
* For handling support of sequences and autoincrement. * For handling support of sequences and autoincrement.
*/ */
private final DbIdentity dbIdentity; private final DbIdentity dbIdentity;
/** /**
* Set to true if table and column comments are included inline with the create statements. * Set to true if table and column comments are included inline with the create statements.
*/ */
protected boolean inlineComments; protected boolean inlineComments;
/** /**
* Default assumes if exists is supported. * Default assumes if exists is supported.
*/ */
protected String dropTableIfExists = "drop table if exists "; protected String dropTableIfExists = "drop table if exists ";
protected String dropTableCascade = ""; protected String dropTableCascade = "";
/** /**
* Default assumes if exists is supported. * Default assumes if exists is supported.
*/ */
protected String dropSequenceIfExists = "drop sequence if exists "; protected String dropSequenceIfExists = "drop sequence if exists ";
protected String foreignKeyOnDelete = "on delete"; protected String foreignKeyOnDelete = "on delete";
protected String foreignKeyOnUpdate = "on update"; protected String foreignKeyOnUpdate = "on update";
protected String identitySuffix = " auto_increment"; protected String identitySuffix = " auto_increment";
protected String identityStartWith = "start with"; protected String identityStartWith = "start with";
protected String identityIncrementBy = "increment by"; protected String identityIncrementBy = "increment by";
@@ -69,64 +60,39 @@ public class PlatformDdl {
protected String sequenceStartWith = "start with"; protected String sequenceStartWith = "start with";
protected String sequenceIncrementBy = "increment by"; protected String sequenceIncrementBy = "increment by";
protected String sequenceCache = "cache"; protected String sequenceCache = "cache";
protected String alterTableIfExists = ""; protected String alterTableIfExists = "";
protected String dropConstraintIfExists = "drop constraint if exists"; protected String dropConstraintIfExists = "drop constraint if exists";
protected String dropIndexIfExists = "drop index if exists "; protected String dropIndexIfExists = "drop index if exists ";
protected String alterColumn = "alter column"; protected String alterColumn = "alter column";
protected String dropUniqueConstraint = "drop constraint"; protected String dropUniqueConstraint = "drop constraint";
protected String addConstraint = "add constraint"; protected String addConstraint = "add constraint";
protected String addColumn = "add column"; protected String addColumn = "add column";
protected String columnSetType = ""; protected String columnSetType = "";
protected String columnSetDefault = "set default"; protected String columnSetDefault = "set default";
protected String columnDropDefault = "drop default"; protected String columnDropDefault = "drop default";
protected String columnSetNotnull = "set not null"; protected String columnSetNotnull = "set not null";
protected String columnSetNull = "set null"; protected String columnSetNull = "set null";
protected String columnNotNull = "not null"; protected String columnNotNull = "not null";
protected String updateNullWithDefault = "update ${table} set ${column} = ${default} where ${column} is null"; protected String updateNullWithDefault = "update ${table} set ${column} = ${default} where ${column} is null";
protected boolean createSchemaSupport; protected boolean createSchemaSupport;
protected String createSchema = "create schema if not exists"; protected String createSchema = "create schema if not exists";
protected String createTable = "create table"; protected String createTable = "create table";
protected String dropColumn = "drop column"; protected String dropColumn = "drop column";
protected String addForeignKeySkipCheck = ""; protected String addForeignKeySkipCheck = "";
protected String uniqueIndex = "unique"; protected String uniqueIndex = "unique";
protected String indexConcurrent = ""; protected String indexConcurrent = "";
protected String createIndexIfNotExists = ""; protected String createIndexIfNotExists = "";
/** /**
* Set false for MsSqlServer to allow multiple nulls for OneToOne mapping. * Set false for MsSqlServer to allow multiple nulls for OneToOne mapping.
*/ */
protected boolean inlineUniqueWhenNullable = true; protected boolean inlineUniqueWhenNullable = true;
protected DbConstraintNaming naming; protected DbConstraintNaming naming;
/** /**
* Generally not desired as then they are not named (used with SQLite). * Generally not desired as then they are not named (used with SQLite).
*/ */
protected boolean inlineForeignKeys; protected boolean inlineForeignKeys;
protected boolean includeStorageEngine; protected boolean includeStorageEngine;
protected final DbDefaultValue dbDefaultValue; protected final DbDefaultValue dbDefaultValue;
protected String fallbackArrayType = "varchar(1000)"; protected String fallbackArrayType = "varchar(1000)";
public PlatformDdl(DatabasePlatform platform) { public PlatformDdl(DatabasePlatform platform) {
@@ -256,7 +222,6 @@ public class PlatformDdl {
* Write the column definition to the create table statement. * Write the column definition to the create table statement.
*/ */
protected void writeColumnDefinition(DdlBuffer buffer, Column column, DdlIdentity identity) { protected void writeColumnDefinition(DdlBuffer buffer, Column column, DdlIdentity identity) {
String columnDefn = convert(column.getType()); String columnDefn = convert(column.getType());
if (identity.useIdentity() && isTrue(column.isPrimaryKey())) { if (identity.useIdentity() && isTrue(column.isPrimaryKey())) {
columnDefn = asIdentityColumn(columnDefn, identity); columnDefn = asIdentityColumn(columnDefn, identity);
@@ -274,7 +239,6 @@ public class PlatformDdl {
if (isTrue(column.isNotnull()) || isTrue(column.isPrimaryKey())) { if (isTrue(column.isNotnull()) || isTrue(column.isPrimaryKey())) {
buffer.appendWithSpace(columnNotNull); buffer.appendWithSpace(columnNotNull);
} }
// add check constraints later as we really want to give them a nice name // add check constraints later as we really want to give them a nice name
// so that the database can potentially provide a nice SQL error // so that the database can potentially provide a nice SQL error
} }
@@ -439,7 +403,6 @@ public class PlatformDdl {
* Return the foreign key constraint when used inline with create table. * Return the foreign key constraint when used inline with create table.
*/ */
public String tableInlineForeignKey(WriteForeignKey request) { public String tableInlineForeignKey(WriteForeignKey request) {
StringBuilder buffer = new StringBuilder(90); StringBuilder buffer = new StringBuilder(90);
buffer.append("foreign key"); buffer.append("foreign key");
appendColumns(request.cols(), buffer); appendColumns(request.cols(), buffer);
@@ -453,7 +416,6 @@ public class PlatformDdl {
* Add foreign key. * Add foreign key.
*/ */
public String alterTableAddForeignKey(DdlOptions options, WriteForeignKey request) { public String alterTableAddForeignKey(DdlOptions options, WriteForeignKey request) {
StringBuilder buffer = new StringBuilder(90); StringBuilder buffer = new StringBuilder(90);
buffer buffer
.append("alter table ").append(quote(request.table())) .append("alter table ").append(quote(request.table()))
@@ -527,7 +489,6 @@ public class PlatformDdl {
* Overridden by MsSqlServer for specific null handling on unique constraints. * Overridden by MsSqlServer for specific null handling on unique constraints.
*/ */
public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns) { public String alterTableAddUniqueConstraint(String tableName, String uqName, String[] columns, String[] nullableColumns) {
StringBuilder buffer = new StringBuilder(90); StringBuilder buffer = new StringBuilder(90);
buffer.append("alter table ").append(quote(tableName)).append(" add constraint ").append(maxConstraintName(uqName)).append(" unique "); buffer.append("alter table ").append(quote(tableName)).append(" add constraint ").append(maxConstraintName(uqName)).append(" unique ");
appendColumns(columns, buffer); appendColumns(columns, buffer);
@@ -535,7 +496,6 @@ public class PlatformDdl {
} }
public void alterTableAddColumn(DdlWrite writer, String tableName, Column column, boolean onHistoryTable, String defaultValue) { public void alterTableAddColumn(DdlWrite writer, String tableName, Column column, boolean onHistoryTable, String defaultValue) {
String convertedType = convert(column.getType()); String convertedType = convert(column.getType());
DdlBuffer buffer = alterTable(writer, tableName).append(addColumn, column.getName()); DdlBuffer buffer = alterTable(writer, tableName).append(addColumn, column.getName());
buffer.append(convertedType); buffer.append(convertedType);
@@ -547,12 +507,10 @@ public class PlatformDdl {
buffer.append(defaultValue); buffer.append(defaultValue);
} }
} }
if (!onHistoryTable) { if (!onHistoryTable) {
if (isTrue(column.isNotnull())) { if (isTrue(column.isNotnull())) {
buffer.appendWithSpace(columnNotNull); buffer.appendWithSpace(columnNotNull);
} }
// check constraints cannot be added in one statement for h2 // check constraints cannot be added in one statement for h2
if (!StringHelper.isNull(column.getCheckConstraint())) { if (!StringHelper.isNull(column.getCheckConstraint())) {
String ddl = alterTableAddCheckConstraint(tableName, column.getCheckConstraintName(), column.getCheckConstraint()); String ddl = alterTableAddCheckConstraint(tableName, column.getCheckConstraintName(), column.getCheckConstraint());
@@ -566,7 +524,6 @@ public class PlatformDdl {
* This method is used from DbTriggerBasedHistoryDdl to add the sysPeriodColumns. * This method is used from DbTriggerBasedHistoryDdl to add the sysPeriodColumns.
*/ */
public void alterTableAddColumn(DdlWrite writer, String tableName, String columnName, String columnType, String defaultValue) { public void alterTableAddColumn(DdlWrite writer, String tableName, String columnName, String columnType, String defaultValue) {
String convertedType = convert(columnType); String convertedType = convert(columnType);
DdlBuffer buffer = alterTable(writer, tableName).append(addColumn, columnName); DdlBuffer buffer = alterTable(writer, tableName).append(addColumn, columnName);
buffer.append(convertedType); buffer.append(convertedType);
@@ -644,18 +601,14 @@ public class PlatformDdl {
* <p> * <p>
* Used by MySql, SQL Server, and HANA as these require all column attributes to * Used by MySql, SQL Server, and HANA as these require all column attributes to
* be set together. * be set together.
* </p>
*/ */
public void alterColumn(DdlWrite writer, AlterColumn alter) { public void alterColumn(DdlWrite writer, AlterColumn alter) {
if (hasValue(alter.getType())) { if (hasValue(alter.getType())) {
alterColumnType(writer, alter); alterColumnType(writer, alter);
} }
if (hasValue(alter.getDefaultValue())) { if (hasValue(alter.getDefaultValue())) {
alterColumnDefault(writer, alter); alterColumnDefault(writer, alter);
} }
if (alter.isNotnull() != null) { if (alter.isNotnull() != null) {
alterColumnNotnull(writer, alter); alterColumnNotnull(writer, alter);
} }
@@ -739,14 +692,14 @@ public class PlatformDdl {
* Use this to generate a prolog for each script (stored procedures) * Use this to generate a prolog for each script (stored procedures)
*/ */
public void generateProlog(DdlWrite writer) { public void generateProlog(DdlWrite writer) {
// do nothing by default
} }
/** /**
* Use this to generate an epilog. Will be added at the end of script * Use this to generate an epilog. Will be added at the end of script
*/ */
public void generateEpilog(DdlWrite writer) { public void generateEpilog(DdlWrite writer) {
// do nothing by default
} }
/** /**