Skip to content

Commit

Permalink
dbeaver#7888 Table columns copy-paste (PG, MySQL, MariaDB)
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Feb 11, 2020
1 parent 092f8ca commit 0716b41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.sql.SQLUtils;
import org.jkiss.dbeaver.model.struct.DBSDataType;
import org.jkiss.dbeaver.model.struct.DBSEntityAttribute;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.cache.DBSObjectCache;
import org.jkiss.utils.CommonUtils;
Expand Down Expand Up @@ -115,8 +116,8 @@ protected MySQLTableColumn createDatabaseObject(final DBRProgressMonitor monitor
MySQLTable table = (MySQLTable) container;

MySQLTableColumn column;
if (copyFrom instanceof MySQLTableColumn) {
column = new MySQLTableColumn(monitor, table, (MySQLTableColumn)copyFrom);
if (copyFrom instanceof DBSEntityAttribute) {
column = new MySQLTableColumn(monitor, table, (DBSEntityAttribute)copyFrom);
} else {
column = new MySQLTableColumn(table);
DBSDataType columnType = findBestDataType(table.getDataSource(), "varchar"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,19 @@ public StringBuilder getNestedDeclaration(DBRProgressMonitor monitor, PostgreTab
}

@Override
protected PostgreTableColumn createDatabaseObject(final DBRProgressMonitor monitor, final DBECommandContext context, final Object container, Object copyFrom, Map<String, Object> options)
{
protected PostgreTableColumn createDatabaseObject(final DBRProgressMonitor monitor, final DBECommandContext context, final Object container, Object copyFrom, Map<String, Object> options) throws DBException {
PostgreTableBase table = (PostgreTableBase) container;

final PostgreTableColumn column = new PostgreTableColumn(table);
column.setName(getNewColumnName(monitor, context, table));
final PostgreDataType dataType = table.getDatabase().getDataType(monitor, PostgreOid.VARCHAR);
column.setDataType(dataType); //$NON-NLS-1$
column.setOrdinalPosition(-1);
final PostgreTableColumn column;
if (copyFrom instanceof PostgreTableColumn) {
column = new PostgreTableColumn(monitor, table, (PostgreTableColumn)copyFrom);
} else {
column = new PostgreTableColumn(table);
column.setName(getNewColumnName(monitor, context, table));
final PostgreDataType dataType = table.getDatabase().getDataType(monitor, PostgreOid.VARCHAR);
column.setDataType(dataType); //$NON-NLS-1$
column.setOrdinalPosition(-1);
}
return column;
}

Expand Down

0 comments on commit 0716b41

Please sign in to comment.