This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 957bb29 support select '' as a from order (#6542)
957bb29 is described below
commit 957bb295173b40c0a73a78c5cdbfbb0a6638997c
Author: cmonkey <[email protected]>
AuthorDate: Fri Jul 31 16:28:33 2020 +0800
support select '' as a from order (#6542)
---
.../java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtil.java | 3 +++
.../org/apache/shardingsphere/sql/parser/sql/util/SQLUtilTest.java | 1 +
2 files changed, 4 insertions(+)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtil.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtil.java
index 0c2c979..bd60e6b 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtil.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtil.java
@@ -95,6 +95,9 @@ public final class SQLUtil {
private static int getParenthesesOffset(final String value) {
int result = 0;
+ if (Strings.isNullOrEmpty(value)) {
+ return result;
+ }
while (Paren.PARENTHESES.getLeftParen() == value.charAt(result)) {
result++;
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtilTest.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtilTest.java
index ac6988a..9d761ba 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtilTest.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/util/SQLUtilTest.java
@@ -88,5 +88,6 @@ public final class SQLUtilTest {
@Test
public void assertGetExpressionWithoutOutsideParentheses() {
assertThat(SQLUtil.getExpressionWithoutOutsideParentheses("((a +
b*c))"), is("a + b*c"));
+ assertThat(SQLUtil.getExpressionWithoutOutsideParentheses(""), is(""));
}
}