提交 e3d0fe99 编写于 作者: S serge-rider

#813 PG sequence DDL


Former-commit-id: e26cc9e1
上级 d9e1e0e3
......@@ -119,7 +119,7 @@ public class GenerateSQLContributor extends CompoundContributionItem {
if (sql.length() > 0) {
sql.append("\n");
}
String definitionText = object.getObjectDefinitionText(monitor).trim();
String definitionText = CommonUtils.notEmpty(object.getObjectDefinitionText(monitor)).trim();
sql.append(definitionText);
if (!definitionText.endsWith(SQLConstants.DEFAULT_STATEMENT_DELIMITER)) {
sql.append(SQLConstants.DEFAULT_STATEMENT_DELIMITER);
......
......@@ -168,7 +168,29 @@ public class PostgreSequence extends PostgreTableBase implements DBSSequence, DB
@Override
public String getObjectDefinitionText(DBRProgressMonitor monitor) throws DBException {
return null;
AdditionalInfo info = getAdditionalInfo(monitor);
StringBuilder sql = new StringBuilder();
sql.append("-- DROP SEQUENCE ").append(getFullyQualifiedName(DBPEvaluationContext.DDL)).append(";\n\n");
sql.append("CREATE SEQUENCE ").append(getFullyQualifiedName(DBPEvaluationContext.DDL));
if (info.getIncrementBy() != null && info.getIncrementBy().longValue() > 0) {
sql.append("\nINCREMENT BY ").append(info.getIncrementBy());
}
if (info.getMinValue() != null && info.getMinValue().longValue() > 0) {
sql.append("\nMINVALUE ").append(info.getMinValue());
} else {
sql.append("\nNO MINVALUE");
}
if (info.getMaxValue() != null && info.getMaxValue().longValue() > 0) {
sql.append("\nMAXVALUE ").append(info.getMaxValue());
} else {
sql.append("\nNO MAXVALUE");
}
if (info.getLastValue() != null && info.getLastValue().longValue() > 0) {
sql.append("\nSTART ").append(info.getLastValue());
}
return sql.toString();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册