You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/07/23 11:19:17 UTC

[shardingsphere] branch master updated: fix 6354 (#6423)

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 9983b71  fix 6354 (#6423)
9983b71 is described below

commit 9983b71cdd1346753df8f812e898eee2226e2527
Author: JingShang Lu <ji...@gmail.com>
AuthorDate: Thu Jul 23 19:18:55 2020 +0800

    fix 6354 (#6423)
    
    * fix 6354
    
    * fix
---
 .../src/main/antlr4/imports/mysql/BaseRule.g4      |  1 +
 .../src/main/antlr4/imports/mysql/Symbol.g4        |  1 +
 .../src/test/resources/case/dml/select.xml         | 25 ++++++++++++++++++++++
 .../test/resources/sql/supported/dml/select.xml    |  1 +
 4 files changed, 28 insertions(+)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index a04c998..1180464 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -381,6 +381,7 @@ simpleExpr
     | ROW? LP_ expr (COMMA_ expr)* RP_
     | EXISTS? subquery
     | LBE_ identifier expr RBE_
+    | identifier JSON_SEPARATOR STRING_
     | matchExpression_
     | caseExpression
     | intervalExpression
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Symbol.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Symbol.g4
index da742da..293561b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Symbol.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Symbol.g4
@@ -57,3 +57,4 @@ BQ_:                 '`';
 QUESTION_:           '?';
 AT_:                 '@';
 SEMI_:               ';';
+JSON_SEPARATOR:      '->>';
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/select.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/select.xml
index 7459335..ea844e8 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/select.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/select.xml
@@ -1886,4 +1886,29 @@
             </and-predicate>
         </where>
     </select>
+
+    <select sql-case-id="select_with_json_separator">
+        <projections start-index="7" stop-index="75">
+            <expression-projection start-index="7" stop-index="41" alias="nation" />
+            <expression-projection start-index="43" stop-index="75" alias="title" />
+        </projections>
+        <table-reference>
+            <table-factor>
+                <table name="tb_content_json" start-index="82" stop-index="98" alias="b" />
+            </table-factor>
+        </table-reference>
+        <where start-index="100" stop-index="119" literal-stop-index="121">
+            <and-predicate>
+                <predicate start-index="106" stop-index="119">
+                    <column-left-value name="content_id" start-index="106" stop-index="117">
+                        <owner stop-index="106" start-index="106" name="b"/>
+                    </column-left-value>
+                    <operator type="=" />
+                    <compare-right-value>
+                        <literal-expression start-index="119" stop-index="119" value="1" />
+                    </compare-right-value>
+                </predicate>
+            </and-predicate>
+        </where>
+    </select>
 </sql-parser-test-cases>
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/select.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/select.xml
index 51a063a..9313654 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/select.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/select.xml
@@ -56,4 +56,5 @@
     <sql-case id="select_with_spatial_function" value="SELECT * FROM t_order WHERE ST_DISTANCE_SPHERE(POINT(113.358772, 23.1273723), POINT(user_id,order_id)) != 0" db-types="MySQL" />
     <sql-case id="select_current_user" value="SELECT CURRENT_USER" db-types="PostgreSQL"/>
     <sql-case id="select_with_match_against" value="SELECT * FROM t_order_item WHERE MATCH(t_order_item.description) AGAINST (? IN NATURAL LANGUAGE MODE) AND user_id = ?" db-types="MySQL" />
+    <sql-case id="select_with_json_separator" value="select content_json->>'$.nation' as nation,content_json->>'$.title' as title from tb_content_json b where b.content_id=1" db-types="MySQL" />
 </sql-cases>