Duplicate column bug #299

This commit is contained in:
yanhuqing
2017-10-25 16:04:49 +08:00
parent 3320e61b8f
commit d0dafa85f4
2 changed files with 10 additions and 15 deletions
@@ -148,10 +148,9 @@ public class GlobalVisitor extends MysqlVisitor {
if (!isTopQuery) {
sqlBuilder.append(" ( ");
}
if (join.isSubQuery() || isTopQuery) {
buildSelect(join);
sqlBuilder.append(" from ");
}
buildSelect(join);
sqlBuilder.append(" from ");
PlanNode left = join.getLeftNode();
MysqlVisitor leftVisitor = new GlobalVisitor(left, false);
@@ -184,22 +183,18 @@ public class GlobalVisitor extends MysqlVisitor {
}
if (join.getOtherJoinOnFilter() != null) {
if (first) {
first = false;
} else {
if (!first) {
joinOnFilterStr.append(" and ");
}
joinOnFilterStr.append(join.getOtherJoinOnFilter());
}
sqlBuilder.append(joinOnFilterStr.toString());
if (join.isSubQuery() || isTopQuery) {
buildWhere(join);
buildGroupBy(join);
buildHaving(join);
buildOrderBy(join);
buildLimit(join);
}
buildWhere(join);
buildGroupBy(join);
buildHaving(join);
buildOrderBy(join);
buildLimit(join);
if (!isTopQuery) {
sqlBuilder.append(" ) ");
@@ -237,7 +237,7 @@ public class MySQLPlanNodeVisitor {
this.tableNode.setSubQuery(true);
if (subQueryTables.getAlias() != null) {
tableNode.alias(subQueryTables.getAlias());
if (tableNode.getSubAlias() == null) {
if (tableNode.getSubAlias() == null && tableNode.type() == PlanNode.PlanNodeType.TABLE) {
tableNode.setSubAlias(tableNode.getAlias());
}
}