DBZ-3966 Serializing hasDefaultValue in JsonTableChangeSerializer
This commit is contained in:
parent
d1cae3f3b7
commit
2987e96c44
@ -91,6 +91,7 @@ private Document toDocument(Column column) {
|
||||
document.setBoolean("autoIncremented", column.isAutoIncremented());
|
||||
document.setBoolean("generated", column.isGenerated());
|
||||
document.setString("comment", column.comment());
|
||||
document.setBoolean("hasDefaultValue", column.hasDefaultValue());
|
||||
|
||||
column.defaultValueExpression().ifPresent(d -> document.setString("defaultValueExpression", d));
|
||||
|
||||
@ -161,10 +162,14 @@ private static Table fromDocument(TableId id, Document document) {
|
||||
columnEditor.comment(columnComment);
|
||||
}
|
||||
|
||||
Boolean hasDefaultValue = v.getBoolean("hasDefaultValue");
|
||||
String defaultValueExpression = v.getString("defaultValueExpression");
|
||||
if (defaultValueExpression != null) {
|
||||
columnEditor.defaultValueExpression(defaultValueExpression);
|
||||
}
|
||||
else if (Boolean.TRUE.equals(hasDefaultValue)) {
|
||||
columnEditor.defaultValueExpression(null);
|
||||
}
|
||||
|
||||
Array enumValues = v.getArray("enumValues");
|
||||
if (enumValues != null && !enumValues.isEmpty()) {
|
||||
|
@ -54,6 +54,14 @@ public void canSerializeAndDeserializeHistoryRecord() throws Exception {
|
||||
.defaultValueExpression("1")
|
||||
.enumValues(Collect.arrayListOf("1", "2"))
|
||||
.create())
|
||||
.addColumn(Column.editor()
|
||||
.name("third")
|
||||
.jdbcType(Types.VARCHAR)
|
||||
.type("VARCHAR")
|
||||
.length(22)
|
||||
.optional(true)
|
||||
.comment("third comment")
|
||||
.create())
|
||||
.setPrimaryKeyNames("first")
|
||||
.setComment("table comment")
|
||||
.create();
|
||||
|
Loading…
Reference in New Issue
Block a user