提交 3e581c40 编写于 作者: S Serge Rider

#487 PG/Oracle: table comment modify


Former-commit-id: 51513319
上级 da4d3b07
......@@ -68,23 +68,26 @@ public class OracleTableManager extends SQLTableManager<OracleTable, OracleSchem
@Override
protected DBEPersistAction[] makeObjectModifyActions(ObjectChangeCommand command)
{
final OracleTable table = command.getObject();
boolean hasComment = command.getProperty("comment") != null;
List<DBEPersistAction> actions = new ArrayList<>(2);
if (!hasComment || command.getProperties().size() > 1) {
if (command.getProperties().size() > 1 || command.getProperty("comment") == null) {
StringBuilder query = new StringBuilder("ALTER TABLE "); //$NON-NLS-1$
query.append(command.getObject().getFullQualifiedName()).append(" "); //$NON-NLS-1$
appendTableModifiers(command.getObject(), command, query);
actions.add(new SQLDatabasePersistAction(query.toString()));
}
if (hasComment) {
addExtraTableActions(actions, command);
return actions.toArray(new DBEPersistAction[actions.size()]);
}
@Override
protected void addExtraTableActions(List<DBEPersistAction> actions, NestedObjectCommand<OracleTable, PropertyHandler> command) {
if (command.getProperty("comment") != null) {
actions.add(new SQLDatabasePersistAction(
"Comment table",
"COMMENT ON TABLE " + table.getFullQualifiedName() +
" IS '" + SQLUtils.escapeString(table.getComment()) + "'"));
"COMMENT ON TABLE " + command.getObject().getFullQualifiedName() +
" IS '" + SQLUtils.escapeString(command.getObject().getDescription()) + "'"));
}
return actions.toArray(new DBEPersistAction[actions.size()]);
}
@Override
......
......@@ -73,23 +73,26 @@ public class PostgreTableManager extends SQLTableManager<PostgreTableBase, Postg
{
final PostgreTableBase table = command.getObject();
List<DBEPersistAction> actions = new ArrayList<>(2);
boolean hasComment = command.getProperty("description") != null;
if (!hasComment || command.getProperties().size() > 1) {
if (command.getProperties().size() > 1 || command.getProperty("description") == null) {
StringBuilder query = new StringBuilder("ALTER TABLE "); //$NON-NLS-1$
query.append(table.getFullQualifiedName()).append(" "); //$NON-NLS-1$
appendTableModifiers(table, command, query);
actions.add(new SQLDatabasePersistAction(query.toString()));
}
addExtraTableActions(actions, command);
if (hasComment) {
return actions.toArray(new DBEPersistAction[actions.size()]);
}
@Override
protected void addExtraTableActions(List<DBEPersistAction> actions, NestedObjectCommand<PostgreTableBase, PropertyHandler> command) {
if (command.getProperty("description") != null) {
actions.add(new SQLDatabasePersistAction(
"Comment table",
"COMMENT ON TABLE " + table.getFullQualifiedName() +
" IS '" + SQLUtils.escapeString(table.getDescription()) + "'"));
"COMMENT ON TABLE " + command.getObject().getFullQualifiedName() +
" IS '" + SQLUtils.escapeString(command.getObject().getDescription()) + "'"));
}
return actions.toArray(new DBEPersistAction[actions.size()]);
}
@Override
......
......@@ -33,6 +33,7 @@ class PostgreDialect extends JDBCSQLDialect {
addSQLKeyword("SHOW");
addSQLKeyword("TYPE");
addSQLKeyword("USER");
addSQLKeyword("COMMENT");
removeSQLKeyword("PUBLIC");
removeSQLKeyword("LENGTH");
removeSQLKeyword("LANGUAGE");
......
......@@ -105,10 +105,16 @@ public abstract class SQLTableManager<OBJECT_TYPE extends JDBCTable, CONTAINER_T
appendTableModifiers(table, tableProps, createQuery);
actions.add( 0, new SQLDatabasePersistAction(ModelMessages.model_jdbc_create_new_table, createQuery.toString()) );
addExtraTableActions(actions, command);
return actions.toArray(new DBEPersistAction[actions.size()]);
}
protected void addExtraTableActions(List<DBEPersistAction> actions, NestedObjectCommand<OBJECT_TYPE, PropertyHandler> command)
{
}
@Override
protected DBEPersistAction[] makeObjectDeleteActions(ObjectDeleteCommand command)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册