提交 550de04e 编写于 作者: S serge-rider

#735 PG indexes filter (hide all unique indexes linked with constraints).

Index create dialog fix
上级 e2f43a51
......@@ -30,6 +30,7 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
......@@ -175,7 +176,11 @@ public abstract class AttributesSelectorDialog extends Dialog {
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
try {
attributes.addAll(CommonUtils.safeCollection(entity.getAttributes(monitor)));
for (DBSEntityAttribute attr : CommonUtils.safeCollection(entity.getAttributes(monitor))) {
if (!DBUtils.isHiddenObject(attr)) {
attributes.add(attr);
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
......
......@@ -52,7 +52,9 @@ public class PostgreIndex extends JDBCTableIndex<PostgreSchema, PostgreTableBase
private List<PostgreIndexColumn> columns = new ArrayList<>();
private long amId;
public PostgreIndex(PostgreTableBase parent, String indexName, ResultSet dbResult) {
private transient boolean isHidden;
public PostgreIndex(DBRProgressMonitor monitor, PostgreTableBase parent, String indexName, ResultSet dbResult) throws DBException {
super(
parent.getContainer(),
parent,
......@@ -71,6 +73,14 @@ public class PostgreIndex extends JDBCTableIndex<PostgreSchema, PostgreTableBase
this.description = JDBCUtils.safeGetString(dbResult, "description");
this.amId = JDBCUtils.safeGetLong(dbResult, "relam");
// Unique key indexes (including PK) are implicit. We don't want to show them separately
if (this.isUnique) {
PostgreTableConstraintBase ownerConstraint = parent.getConstraint(monitor, getName());
if (ownerConstraint != null && ownerConstraint.getConstraintType().isUnique()) {
this.isHidden = true;
}
}
}
public PostgreIndex(PostgreTableBase parent, String name, DBSIndexType indexType, boolean unique) {
......@@ -188,7 +198,7 @@ public class PostgreIndex extends JDBCTableIndex<PostgreSchema, PostgreTableBase
@Override
public boolean isHidden() {
return isPrimary;
return isHidden;
}
@Override
......
......@@ -654,6 +654,7 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj
throws SQLException, DBException
{
return new PostgreIndex(
session.getProgressMonitor(),
parent,
indexName,
dbResult);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册