提交 ae89496f 编写于 作者: C Charly

Merged Identity Column Information with AutoIncrement Info

上级 a514ae77
......@@ -35,6 +35,7 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.utils.CommonUtils;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -94,7 +95,7 @@ public class ExasolTableColumnManager extends SQLTableColumnManager<ExasolTableC
if (!command.getProperties().isEmpty()) {
final String deltaSQL = exasolColumn.getName() + " " + exasolColumn.getFormatType()
+ " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue())
+ " " + (exasolColumn.isIdentity() ? " IDENTITY " + exasolColumn.getIdentityValue().toString() : "")
+ " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue())
+ " " + (exasolColumn.isRequired() ? "NOT NULL" : "NULL");
if (!deltaSQL.isEmpty()) {
String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
......@@ -109,6 +110,22 @@ public class ExasolTableColumnManager extends SQLTableColumnManager<ExasolTableC
}
}
private String formatIdentiy(Boolean isAutoGenerated,BigDecimal identityValue)
{
String ret = "";
if (isAutoGenerated)
{
ret = "IDENTITY ";
if (identityValue != null)
{
ret = ret + identityValue.toString() + " ";
}
}
return ret;
}
// -------
// Helpers
......
......@@ -28,21 +28,26 @@ import org.jkiss.dbeaver.model.DBPHiddenObject;
import org.jkiss.dbeaver.model.DBPNamedObject2;
import org.jkiss.dbeaver.model.impl.DBPositiveNumberTransformer;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCColumnKeyType;
import org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableColumn;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSDataType;
import org.jkiss.dbeaver.model.struct.DBSTypedObjectEx;
import org.jkiss.dbeaver.model.struct.rdb.DBSTableColumn;
import org.jkiss.utils.CommonUtils;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
/**
* @author Karl Griesser
*/
public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
implements DBSTableColumn, DBSTypedObjectEx, DBPHiddenObject, DBPNamedObject2 {
implements DBSTableColumn, DBSTypedObjectEx, DBPHiddenObject, DBPNamedObject2, JDBCColumnKeyType {
private ExasolDataType dataType;
private Boolean identity;
......@@ -75,7 +80,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
this.identityValue = JDBCUtils.safeGetBigDecimal(dbResult, "COLUMN_IDENTITY");
this.remarks = JDBCUtils.safeGetString(dbResult, "COLUMN_COMMENT");
this.dataType = tableBase.getDataSource().getDataType(monitor, JDBCUtils.safeGetString(dbResult, "TYPE_NAME"));
this.keySeq = JDBCUtils.safeGetInteger(dbResult, "KEY_SEQ");
this.changed = true;
......@@ -211,11 +215,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
super.setDefaultValue(defaultValue);
}
@Property(viewable = true, editable = true, updatable = true, order = 45)
public Boolean isIdentity() {
return identity;
}
public void setIdentity(Boolean identity) {
this.identity = identity;
}
......@@ -231,11 +230,6 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
this.remarks = remarks;
}
@Property(viewable = false, order = 120)
public Integer getKeySeq() {
return keySeq;
}
@Property(viewable = false, order = 121)
public Boolean isDistKey() {
return isInDistKey;
......@@ -247,6 +241,18 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
public boolean isHidden() {
return false;
}
@Override
@Property(viewable = true, editable = true, updatable = true, order = 45)
public boolean isAutoGenerated()
{
return this.identity;
}
public void setAutoGenerated(Boolean identity)
{
this.identity = identity;
}
public String getFormatType() {
if (changed) {
......@@ -264,5 +270,34 @@ public class ExasolTableColumn extends JDBCTableColumn<ExasolTableBase>
return this.formatType;
}
@Override
@Property(viewable = true, order = 80)
public boolean isInUniqueKey()
{
ExasolTableBase table = (ExasolTable) getTable();
try {
final Collection<ExasolTableUniqueKey> uniqueKeysCache = table.getConstraints(VoidProgressMonitor.INSTANCE);
if (!CommonUtils.isEmpty(uniqueKeysCache))
{
for (ExasolTableUniqueKey key : uniqueKeysCache)
{
if (key.hasColumn(this))
return true;
}
}
} catch ( DBException e)
{
return false;
}
return false;
}
@Override
public boolean isInReferenceKey()
{
// don't need this one
return false;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册