Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
50e8abca
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
50e8abca
编写于
7月 03, 2020
作者:
J
JingShang Lu
提交者:
GitHub
7月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix rewrite for subquery in from (#6259)
上级
4d54d595
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
0 deletion
+13
-0
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/select.xml
...e-sharding-rewrite/src/test/resources/sharding/select.xml
+5
-0
shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/dml/SelectStatementContext.java
...l/parser/binder/statement/dml/SelectStatementContext.java
+8
-0
未找到文件。
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/select.xml
浏览文件 @
50e8abca
...
...
@@ -27,6 +27,11 @@
<output
sql=
"SELECT * FROM t_account_0 WHERE account_id = 100"
/>
</rewrite-assertion>
<rewrite-assertion
id=
"select_with_subquery"
db-type=
"MySQL"
>
<input
sql=
"SELECT * FROM (select * from t_account where account_id=?) a WHERE account_id = 100"
/>
<output
sql=
"SELECT * FROM (select * from t_account_0 where account_id=?) a WHERE account_id = 100"
/>
</rewrite-assertion>
<rewrite-assertion
id=
"select_without_sharding_value_for_parameters"
>
<input
sql=
"SELECT * FROM db.t_account WHERE amount = ?"
parameters=
"1000"
/>
<output
sql=
"SELECT * FROM db.t_account_0 WHERE amount = ?"
parameters=
"1000"
/>
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-binder/src/main/java/org/apache/shardingsphere/sql/parser/binder/statement/dml/SelectStatementContext.java
浏览文件 @
50e8abca
...
...
@@ -56,6 +56,7 @@ import org.apache.shardingsphere.sql.parser.sql.segment.dml.predicate.WhereSegme
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.OwnerAvailable
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.OwnerSegment
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SimpleTableSegment
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.table.SubqueryTableSegment
;
import
org.apache.shardingsphere.sql.parser.sql.statement.dml.SelectStatement
;
import
org.apache.shardingsphere.sql.parser.sql.util.SQLUtil
;
...
...
@@ -311,6 +312,13 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
if
(
null
!=
tableFactorSegment
.
getTable
()
&&
tableFactorSegment
.
getTable
()
instanceof
SimpleTableSegment
)
{
result
.
add
((
SimpleTableSegment
)
tableFactorSegment
.
getTable
());
}
// TODO subquery in from support not use alias
if
(
null
!=
tableFactorSegment
.
getTable
()
&&
tableFactorSegment
.
getTable
()
instanceof
SubqueryTableSegment
)
{
SelectStatement
subselect
=
((
SubqueryTableSegment
)
tableFactorSegment
.
getTable
()).
getSubquery
().
getSelect
();
for
(
TableReferenceSegment
each
:
subselect
.
getTableReferences
())
{
result
.
addAll
(
getTablesFromTableReference
(
each
));
}
}
if
(
null
!=
tableFactorSegment
.
getTableReferences
()
&&
!
tableFactorSegment
.
getTableReferences
().
isEmpty
())
{
for
(
TableReferenceSegment
each:
tableFactorSegment
.
getTableReferences
())
{
result
.
addAll
(
getTablesFromTableReference
(
each
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录