Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
46a27255
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,发现更多精彩内容 >>
未验证
提交
46a27255
编写于
2月 18, 2020
作者:
L
Liang Zhang
提交者:
GitHub
2月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
decouple find SchemaSegment with show index statement (#4354)
上级
f0a94655
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
4 deletion
+17
-4
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
...r/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
+13
-0
shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDALVisitor.java
...ardingsphere/sql/parser/visitor/impl/MySQLDALVisitor.java
+1
-0
shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/dal/impl/ShowIndexStatementAssert.java
.../asserts/statement/dal/impl/ShowIndexStatementAssert.java
+3
-4
未找到文件。
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java
浏览文件 @
46a27255
...
...
@@ -17,8 +17,10 @@
package
org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql
;
import
com.google.common.base.Optional
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.SchemaSegment
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment
;
import
org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement
;
import
org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAvailable
;
...
...
@@ -31,4 +33,15 @@ import org.apache.shardingsphere.sql.parser.sql.statement.generic.TableSegmentAv
public
final
class
ShowIndexStatement
extends
DALStatement
implements
TableSegmentAvailable
{
private
TableSegment
table
;
private
SchemaSegment
schema
;
/**
* Get schema.
*
* @return schema
*/
public
Optional
<
SchemaSegment
>
getSchema
()
{
return
Optional
.
fromNullable
(
schema
);
}
}
shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/visitor/impl/MySQLDALVisitor.java
浏览文件 @
46a27255
...
...
@@ -134,6 +134,7 @@ public final class MySQLDALVisitor extends MySQLVisitor {
SchemaNameContext
schemaNameContext
=
ctx
.
fromSchema
().
schemaName
();
SchemaSegment
schemaSegment
=
new
SchemaSegment
(
schemaNameContext
.
getStart
().
getStartIndex
(),
schemaNameContext
.
getStop
().
getStopIndex
(),
(
IdentifierValue
)
visit
(
schemaNameContext
));
result
.
getAllSQLSegments
().
add
(
schemaSegment
);
result
.
setSchema
(
schemaSegment
);
}
if
(
null
!=
ctx
.
fromTable
())
{
FromTableSegment
fromTableSegment
=
(
FromTableSegment
)
visitFromTable
(
ctx
.
fromTable
());
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/java/org/apache/shardingsphere/sql/parser/integrate/asserts/statement/dal/impl/ShowIndexStatementAssert.java
浏览文件 @
46a27255
...
...
@@ -23,7 +23,6 @@ import org.apache.shardingsphere.sql.parser.integrate.asserts.SQLCaseAssertConte
import
org.apache.shardingsphere.sql.parser.integrate.asserts.segment.schema.SchemaAssert
;
import
org.apache.shardingsphere.sql.parser.integrate.asserts.segment.table.TableAssert
;
import
org.apache.shardingsphere.sql.parser.integrate.jaxb.domain.statement.dal.ShowIndexStatementTestCase
;
import
org.apache.shardingsphere.sql.parser.sql.segment.generic.SchemaSegment
;
import
org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql.ShowIndexStatement
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
...
...
@@ -58,10 +57,10 @@ public final class ShowIndexStatementAssert {
private
static
void
assertSchema
(
final
SQLCaseAssertContext
assertContext
,
final
ShowIndexStatement
actual
,
final
ShowIndexStatementTestCase
expected
)
{
if
(
null
!=
expected
.
getSchema
())
{
assertTrue
(
assertContext
.
getText
(
"Actual schema segment should exist."
),
actual
.
findSQLSegment
(
SchemaSegment
.
class
).
isPresent
());
SchemaAssert
.
assertIs
(
assertContext
,
actual
.
findSQLSegment
(
SchemaSegment
.
class
).
get
(),
expected
.
getSchema
());
assertTrue
(
assertContext
.
getText
(
"Actual schema segment should exist."
),
actual
.
getSchema
(
).
isPresent
());
SchemaAssert
.
assertIs
(
assertContext
,
actual
.
getSchema
(
).
get
(),
expected
.
getSchema
());
}
else
{
assertFalse
(
assertContext
.
getText
(
"Actual schema segment should not exist."
),
actual
.
findSQLSegment
(
SchemaSegment
.
class
).
isPresent
());
assertFalse
(
assertContext
.
getText
(
"Actual schema segment should not exist."
),
actual
.
getSchema
(
).
isPresent
());
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录