Skip to content

Commit

Permalink
fix #81
Browse files Browse the repository at this point in the history
  • Loading branch information
hanahmily authored and gaoht committed May 24, 2016
1 parent bf13298 commit 502a0f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public class OrVisitor extends AbstractMySQLVisitor {
public OrVisitor(final SQLASTOutputVisitor dependencyVisitor) {
setParameters(dependencyVisitor.getParameters());
SQLVisitor visitor = (SQLVisitor) dependencyVisitor;
String currentTableName = null == visitor.getParseContext().getCurrentTable() ? "" : visitor.getParseContext().getCurrentTable().getName();
getParseContext().setCurrentTable(currentTableName, Optional.<String>absent());
if (null != visitor.getParseContext().getCurrentTable()) {
getParseContext().setCurrentTable(visitor.getParseContext().getCurrentTable().getName(), Optional.<String>absent());
}
getParseContext().getParsedResult().getRouteContext().getTables().addAll(visitor.getParseContext().getParsedResult().getRouteContext().getTables());
getParseContext().setShardingColumns(visitor.getParseContext().getShardingColumns());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,23 @@
<table name="travel_record" />
</tables>
</assert>

<assert id="assertOrJoin" sql="select u.id, i.name from user u, item i where u.id = i.id and (i.id = 1 or i.id = 2)" expected-sql="SELECT [Token(u)].id, [Token(i)].name FROM [Token(user)] u, [Token(item)] i WHERE u.id = i.id AND (i.id = 1 OR i.id = 2)">
<tables>
<table name="user" alias="u"/>
<table name="item" alias="i"/>
</tables>
<condition-contexts>
<condition-context>
<condition column-name="id" table-name="item" operator="EQUAL">
<value value="2" type="java.lang.Integer" />
</condition>
</condition-context>
<condition-context>
<condition column-name="id" table-name="item" operator="EQUAL">
<value value="1" type="java.lang.Integer" />
</condition>
</condition-context>
</condition-contexts>
</assert>
</asserts>
4 changes: 4 additions & 0 deletions sharding-jdbc-doc/content/post/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ weight = 1

## 1.2.2-SNAPSHOT

### 缺陷修正

1. [ISSUE #63](https://github.com/dangdangdotcom/sharding-jdbc/issues/81) 关联表查询使用or查询条件解析结果异常

## 1.2.1

### 结构调整
Expand Down

0 comments on commit 502a0f0

Please sign in to comment.