提交 90683da1 编写于 作者: S serge-rider

#24 Partner license

上级 582ae0ac
......@@ -20,7 +20,6 @@ import org.eclipse.swt.graphics.Image;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer;
import org.jkiss.dbeaver.model.navigator.DBNNode;
......@@ -105,6 +104,13 @@ class SQLCompletionAnalyzer
if (rootObject != null) {
makeProposalsFromChildren(rootObject, null);
}
if (request.queryType == SQLCompletionProcessor.QueryType.JOIN && !request.proposals.isEmpty() && dataSource instanceof DBSObjectContainer) {
// Filter out non-joinable tables
DBSObject leftTable = getTableFromAlias((DBSObjectContainer) dataSource, null);
if (leftTable != null) {
filterNonJoinableProposals(leftTable);
}
}
} else {
DBSObject rootObject = null;
if (request.queryType == SQLCompletionProcessor.QueryType.COLUMN && dataSource instanceof DBSObjectContainer) {
......@@ -132,6 +138,10 @@ class SQLCompletionAnalyzer
}
}
private void filterNonJoinableProposals(DBSObject leftTable) {
// Remove all table proposals which don't have FKs between them and leftTable
}
private void makeDataSourceProposals()
{
DBPDataSource dataSource = request.editor.getDataSource();
......@@ -473,26 +483,18 @@ class SQLCompletionAnalyzer
} else if (!matchedObjects.isEmpty()) {
if (startPart != null) {
if (simpleMode) {
Collections.sort(matchedObjects, new Comparator<DBSObject>() {
@Override
public int compare(DBSObject o1, DBSObject o2) {
return o1.getName().compareTo(o2.getName());
}
});
matchedObjects.sort(Comparator.comparing(DBPNamedObject::getName));
} else {
Collections.sort(matchedObjects, new Comparator<DBSObject>() {
@Override
public int compare(DBSObject o1, DBSObject o2) {
int score1 = scoredMatches.get(o1.getName());
int score2 = scoredMatches.get(o2.getName());
if (score1 == score2) {
if (o1 instanceof DBSAttributeBase) {
return ((DBSAttributeBase) o1).getOrdinalPosition() - ((DBSAttributeBase) o2).getOrdinalPosition();
}
return o1.getName().compareTo(o2.getName());
matchedObjects.sort((o1, o2) -> {
int score1 = scoredMatches.get(o1.getName());
int score2 = scoredMatches.get(o2.getName());
if (score1 == score2) {
if (o1 instanceof DBSAttributeBase) {
return ((DBSAttributeBase) o1).getOrdinalPosition() - ((DBSAttributeBase) o2).getOrdinalPosition();
}
return score2 - score1;
return o1.getName().compareTo(o2.getName());
}
return score2 - score1;
});
}
}
......
......@@ -58,6 +58,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
enum QueryType {
TABLE,
JOIN,
COLUMN
}
......@@ -121,6 +122,8 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
("(".equals(wordDetector.getPrevDelimiter()) || ",".equals(wordDetector.getPrevDelimiter())))
{
request.queryType = QueryType.COLUMN;
} else if (SQLConstants.KEYWORD_JOIN.equals(prevKeyWord)) {
request.queryType = QueryType.JOIN;
} else {
request.queryType = QueryType.TABLE;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册