提交 4699e430 编写于 作者: S Serge Rider

FK create dialog fix (remove unique key dups, shwo unique key type)

上级 0c547b9a
......@@ -636,7 +636,7 @@ public class EditForeignKeyPage extends BaseObjectEditPage {
final Collection<? extends DBSTableIndex> indexes = ((DBSTable)refTable).getIndexes(monitor);
if (!CommonUtils.isEmpty(indexes)) {
for (DBSTableIndex constraint : indexes) {
if (constraint.isUnique()) {
if (constraint.isUnique() && isConstraintIndex(monitor, curConstraints, constraint)) {
curConstraints.add(constraint);
}
}
......@@ -648,7 +648,7 @@ public class EditForeignKeyPage extends BaseObjectEditPage {
});
}
for (DBSEntityConstraint constraint : curConstraints) {
uniqueKeyCombo.add(constraint.getName());
uniqueKeyCombo.add(constraint.getName() + " (" + constraint.getConstraintType().getLocalizedName() + ")");
}
if (uniqueKeyCombo.getItemCount() == 0) {
if (curRefTable == null) {
......@@ -685,6 +685,20 @@ public class EditForeignKeyPage extends BaseObjectEditPage {
updatePageState();
}
private boolean isConstraintIndex(DBRProgressMonitor monitor, List<DBSEntityConstraint> constraints, DBSTableIndex index) throws DBException {
List<? extends DBSTableIndexColumn> iAttrs = index.getAttributeReferences(monitor);
for (DBSEntityConstraint constraint : constraints) {
if (constraint instanceof DBSEntityReferrer) {
List<? extends DBSEntityAttributeRef> cAttrs = ((DBSEntityReferrer) constraint).getAttributeReferences(monitor);
if (CommonUtils.equalObjects(iAttrs, cAttrs)) {
return true;
}
}
}
return false;
}
private void handleUniqueKeySelect()
{
fkColumns.clear();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册