use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by serge-rider.
the class ExasolTableColumnManager method addObjectModifyActions.
// -----
// Alter
// -----
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command) {
ExasolTableColumn exasolColumn = command.getObject();
if (!command.getProperties().isEmpty()) {
// build nullability tring
String nullability = "";
if (exasolColumn.isOriRequired() != null && exasolColumn.isOriRequired() != exasolColumn.isRequired())
nullability = exasolColumn.isRequired() ? "NOT NULL" : "NULL";
final String deltaSQL = exasolColumn.getName() + " " + exasolColumn.getFormatType() + " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue()) + " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue()) + " " + nullability;
if (!deltaSQL.isEmpty()) {
String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sqlAlterColumn));
}
}
// Comment
DBEPersistAction commentAction = buildCommentAction(exasolColumn);
if (commentAction != null) {
actionList.add(commentAction);
}
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by dbeaver.
the class ExasolTableColumnManager method addObjectModifyActions.
// -----
// Alter
// -----
@Override
protected void addObjectModifyActions(List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
ExasolTableColumn exasolColumn = command.getObject();
if (!command.getProperties().isEmpty()) {
// build nullability tring
String nullability = "";
if (exasolColumn.isOriRequired() != null && exasolColumn.isOriRequired() != exasolColumn.isRequired())
nullability = exasolColumn.isRequired() ? "NOT NULL" : "NULL";
final String deltaSQL = exasolColumn.getName() + " " + exasolColumn.getFormatType() + " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue()) + " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue()) + " " + nullability;
if (!deltaSQL.isEmpty()) {
String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sqlAlterColumn));
}
}
// Comment
DBEPersistAction commentAction = buildCommentAction(exasolColumn);
if (commentAction != null) {
actionList.add(commentAction);
}
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by dbeaver.
the class ExasolTableColumnManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final ExasolTableColumn column = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by serge-rider.
the class ExasolTableIndexCache method fetchObjectRow.
@Override
protected ExasolTableIndexColumn[] fetchObjectRow(JDBCSession session, ExasolTable parent, ExasolTableIndex forObject, JDBCResultSet resultSet) throws SQLException, DBException {
// ToDo: fix regex
Matcher m = indexCols.matcher(JDBCUtils.safeGetString(resultSet, "REMARKS"));
String[] colString;
ArrayList<ExasolTableIndexColumn> indexCols = new ArrayList<ExasolTableIndexColumn>();
if (m.find()) {
colString = m.group(1).split(",");
for (int i = 0; i < colString.length; i++) {
ExasolTableColumn tableColumn = colString[i] == null ? null : parent.getAttribute(session.getProgressMonitor(), colString[i]);
indexCols.add(new ExasolTableIndexColumn(forObject, tableColumn, i + 1));
}
}
ExasolTableIndexColumn[] arrayIndexCols = new ExasolTableIndexColumn[indexCols.size()];
arrayIndexCols = indexCols.toArray(arrayIndexCols);
return arrayIndexCols;
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by serge-rider.
the class ExasolTablePartitionColumnCache method getAllObjects.
@Override
public Collection<ExasolTablePartitionColumn> getAllObjects(DBRProgressMonitor monitor, ExasolTable owner) throws DBException {
if (tablePartitionColumns.isEmpty() && !super.fullCache) {
for (ExasolTableColumn col : owner.getAttributes(monitor)) {
if (col.getPartitionKeyOrdinalPosition() != null) {
tablePartitionColumns.add(new ExasolTablePartitionColumn(owner, col, col.getPartitionKeyOrdinalPosition().intValue()));
}
}
sortPartitionColumns();
super.setCache(tablePartitionColumns);
}
return tablePartitionColumns;
}
Aggregations