use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by serge-rider.
the class GenericTableColumnManager method getNestedDeclaration.
@Override
public StringBuilder getNestedDeclaration(GenericTable owner, DBECommandAbstract<GenericTableColumn> command) {
StringBuilder decl = super.getNestedDeclaration(owner, command);
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 FireBirdUtils method getViewSourceWithHeader.
public static String getViewSourceWithHeader(DBRProgressMonitor monitor, GenericTableBase view, String source) throws DBException {
Version version = getFireBirdServerVersion(view.getDataSource());
StringBuilder sql = new StringBuilder();
sql.append("CREATE ");
if (version.getMajor() > 2 || (version.getMajor() == 2 && version.getMinor() >= 5)) {
sql.append("OR ALTER ");
}
sql.append("VIEW ").append(view.getName()).append(" ");
Collection<? extends GenericTableColumn> columns = view.getAttributes(monitor);
if (columns != null) {
sql.append("(");
boolean first = true;
for (GenericTableColumn column : columns) {
if (!first) {
sql.append(", ");
}
first = false;
sql.append(DBUtils.getQuotedIdentifier(column));
}
sql.append(")\n");
}
sql.append("AS\n").append(source);
return sql.toString();
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by dbeaver.
the class FireBirdTableColumnManager 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()) + " ALTER 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 dbeaver.
the class FireBirdTableColumnManager method addObjectReorderActions.
// /////////////////////////////////////////////
// Reorder
@Override
protected void addObjectReorderActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectReorderCommand command, Map<String, Object> options) {
final GenericTableColumn column = command.getObject();
actions.add(new SQLDatabasePersistAction("Reorder column", "ALTER TABLE " + DBUtils.getQuotedIdentifier(command.getObject().getTable()) + " ALTER COLUMN " + DBUtils.getQuotedIdentifier(command.getObject()) + " POSITION " + column.getOrdinalPosition()));
}
use of org.jkiss.dbeaver.ext.generic.model.GenericTableColumn in project dbeaver by dbeaver.
the class GenericTableColumnManager method createDatabaseObject.
@Override
protected GenericTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, Object container, Object copyFrom, Map<String, Object> options) throws DBException {
GenericTableBase tableBase = (GenericTableBase) container;
DBSDataType columnType = findBestDataType(tableBase.getDataSource(), DBConstants.DEFAULT_DATATYPE_NAMES);
int columnSize = columnType != null && columnType.getDataKind() == DBPDataKind.STRING ? 100 : 0;
GenericTableColumn column = tableBase.getDataSource().getMetaModel().createTableColumnImpl(monitor, null, tableBase, getNewColumnName(monitor, context, tableBase), columnType == null ? "INTEGER" : columnType.getName(), columnType == null ? Types.INTEGER : columnType.getTypeID(), columnType == null ? Types.INTEGER : columnType.getTypeID(), -1, columnSize, columnSize, null, null, 10, false, null, null, false, false);
column.setPersisted(false);
return column;
}
Aggregations