[#6987] Add DDLFlag.COMMENT to extract COMMENT statements from DSLContext.ddl()
This commit is contained in:
parent
af5fd2f80e
commit
e841e200d7
@ -145,24 +145,32 @@ final class DDL {
|
||||
else
|
||||
queries.addAll(alterTableAddConstraints(table));
|
||||
|
||||
if (flags.contains(COMMENT)) {
|
||||
String tComment = table.getComment();
|
||||
|
||||
if (!StringUtils.isEmpty(tComment))
|
||||
queries.add(ctx.commentOnTable(table).is(tComment));
|
||||
|
||||
for (Field<?> field : table.fields()) {
|
||||
String fComment = field.getComment();
|
||||
|
||||
if (!StringUtils.isEmpty(fComment))
|
||||
queries.add(ctx.commentOnColumn(field).is(fComment));
|
||||
}
|
||||
}
|
||||
queries.addAll(commentOn(table));
|
||||
}
|
||||
|
||||
return ctx.queries(queries);
|
||||
}
|
||||
|
||||
private List<Query> commentOn(Table<?> table) {
|
||||
List<Query> result = new ArrayList<Query>();
|
||||
|
||||
if (flags.contains(COMMENT)) {
|
||||
String tComment = table.getComment();
|
||||
|
||||
if (!StringUtils.isEmpty(tComment))
|
||||
result.add(ctx.commentOnTable(table).is(tComment));
|
||||
|
||||
for (Field<?> field : table.fields()) {
|
||||
String fComment = field.getComment();
|
||||
|
||||
if (!StringUtils.isEmpty(fComment))
|
||||
result.add(ctx.commentOnColumn(field).is(fComment));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
final Queries queries(Schema schema) {
|
||||
List<Query> queries = new ArrayList<Query>();
|
||||
|
||||
@ -200,6 +208,10 @@ final class DDL {
|
||||
for (Constraint constraint : foreignKeys(table))
|
||||
queries.add(ctx.alterTable(table).add(constraint));
|
||||
|
||||
if (flags.contains(COMMENT))
|
||||
for (Table<?> table : schema.getTables())
|
||||
queries.addAll(commentOn(table));
|
||||
|
||||
return ctx.queries(queries);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user