use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by serge-rider.
the class SQLiteTableColumnManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final GenericTableColumn column = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + DBUtils.getQuotedIdentifier(column.getTable()) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by serge-rider.
the class VerticaTableColumnManager method addObjectModifyActions.
/**
* Copy-pasted from PostgreSQL implementation.
* TODO: Vertica is originally based on PG. Maybe we should refactor this stuff somehow.
*/
@Override
protected void addObjectModifyActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
final GenericTableColumn column = command.getObject();
String prefix = "ALTER TABLE " + DBUtils.getObjectFullName(column.getTable(), DBPEvaluationContext.DDL) + " ALTER COLUMN " + DBUtils.getQuotedIdentifier(column) + " ";
String typeClause = column.getFullTypeName();
if (command.getProperty(DBConstants.PROP_ID_TYPE_NAME) != null || command.getProperty("maxLength") != null || command.getProperty("precision") != null || command.getProperty("scale") != null) {
actionList.add(new SQLDatabasePersistAction("Set column type", prefix + "SET DATA TYPE " + typeClause));
}
if (command.getProperty(DBConstants.PROP_ID_REQUIRED) != null) {
actionList.add(new SQLDatabasePersistAction("Set column nullability", prefix + (column.isRequired() ? "SET" : "DROP") + " NOT NULL"));
}
if (command.getProperty(DBConstants.PROP_ID_DEFAULT_VALUE) != null) {
if (CommonUtils.isEmpty(column.getDefaultValue())) {
actionList.add(new SQLDatabasePersistAction("Drop column default", prefix + "DROP DEFAULT"));
} else {
actionList.add(new SQLDatabasePersistAction("Set column default", prefix + "SET DEFAULT " + column.getDefaultValue()));
}
}
super.addObjectModifyActions(monitor, executionContext, actionList, command, options);
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by serge-rider.
the class VerticaTableColumnManager method getNestedDeclaration.
@Override
public StringBuilder getNestedDeclaration(DBRProgressMonitor monitor, GenericTableBase owner, DBECommandAbstract<GenericTableColumn> command, Map<String, Object> options) {
StringBuilder decl = super.getNestedDeclaration(monitor, owner, command, options);
final GenericTableColumn column = command.getObject();
if (column.isAutoIncrement()) {
final String autoIncrementClause = column.getDataSource().getMetaModel().getAutoIncrementClause(column);
if (autoIncrementClause != null && !autoIncrementClause.isEmpty()) {
// $NON-NLS-1$
decl.append(" ").append(autoIncrementClause);
}
}
return decl;
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by dbeaver.
the class GenericTableColumnManager method getNestedDeclaration.
@Override
public StringBuilder getNestedDeclaration(DBRProgressMonitor monitor, GenericTableBase owner, DBECommandAbstract<GenericTableColumn> command, Map<String, Object> options) {
StringBuilder decl = super.getNestedDeclaration(monitor, owner, command, options);
final GenericTableColumn column = command.getObject();
if (column.isAutoIncrement()) {
final String autoIncrementClause = column.getDataSource().getMetaModel().getAutoIncrementClause(column);
if (autoIncrementClause != null && !autoIncrementClause.isEmpty()) {
// $NON-NLS-1$
decl.append(" ").append(autoIncrementClause);
}
}
return decl;
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by dbeaver.
the class SQLiteTableColumnManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final GenericTableColumn column = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + DBUtils.getQuotedIdentifier(column.getTable()) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
Aggregations