[Clickhouse] Refactored columnNotNull

This commit is contained in:
Roland Praml
2022-03-07 16:41:27 +01:00
parent 9bcba0b80d
commit c3bdac5271
2 changed files with 5 additions and 14 deletions
@@ -14,6 +14,7 @@ public class ClickHouseDdl extends PlatformDdl {
super(platform);
this.includeStorageEngine = true;
this.identitySuffix = "";
this.columnNotNull = null;
}
@Override
@@ -68,11 +69,6 @@ public class ClickHouseDdl extends PlatformDdl {
return null;
}
@Override
protected void writeColumnNotNull(DdlBuffer buffer) {
// do nothing
}
@Override
public void addTableComment(DdlBuffer apply, String tableName, String tableComment) {
// do nothing
@@ -97,6 +97,8 @@ public class PlatformDdl {
protected String columnSetNull = "set null";
protected String columnNotNull = "not null";
protected String updateNullWithDefault = "update ${table} set ${column} = ${default} where ${column} is null";
protected String createTable = "create table";
@@ -272,20 +274,13 @@ public class PlatformDdl {
}
}
if (isTrue(column.isNotnull()) || isTrue(column.isPrimaryKey())) {
writeColumnNotNull(buffer);
buffer.appendWithSpace(columnNotNull);
}
// 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
}
/**
* Allow for platform overriding (e.g. ClickHouse).
*/
protected void writeColumnNotNull(DdlBuffer buffer) {
buffer.append(" not null");
}
/**
* Returns the check constraint.
*/
@@ -556,7 +551,7 @@ public class PlatformDdl {
if (!onHistoryTable) {
if (isTrue(column.isNotnull())) {
writeColumnNotNull(buffer);
buffer.appendWithSpace(columnNotNull);
}
buffer.append(addColumnSuffix);
buffer.endOfStatement();