提交 993fbe1b 编写于 作者: S serge-rider

#3004 SQL join generator fix (use AND)

上级 cd5c8816
......@@ -923,13 +923,18 @@ public final class SQLUtils {
}
private static String generateTablesJoin(DBRProgressMonitor monitor, DBSTableForeignKey fk, String leftAlias, String rightAlias) throws DBException {
boolean hasCriteria = false;
StringBuilder joinSQL = new StringBuilder();
for (DBSEntityAttributeRef ar : fk.getAttributeReferences(monitor)) {
if (ar instanceof DBSTableForeignKeyColumn) {
if (hasCriteria) {
joinSQL.append(" AND ");
}
DBSTableForeignKeyColumn fkc = (DBSTableForeignKeyColumn)ar;
joinSQL
.append(leftAlias).append(".").append(DBUtils.getQuotedIdentifier(fkc)).append(" = ")
.append(rightAlias).append(".").append(DBUtils.getQuotedIdentifier(fkc.getReferencedColumn()));
hasCriteria = true;
}
}
return joinSQL.toString();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册