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 41fc261  fixed on duplicate key update statement parse error
     new 5851681  Merge pull request #6958 from strongduanmu/issue-6942-dev
41fc261 is described below

commit 41fc2618b2228970053d2faec1aefbff5bf5dd86
Author: strongduanmu <[email protected]>
AuthorDate: Fri Aug 21 00:23:23 2020 +0800

    fixed on duplicate key update statement parse error
---
 .../parser/mysql/visitor/impl/MySQLDMLVisitor.java |  1 -
 .../src/test/resources/case/dml/insert.xml         | 34 ++++++++++++++++++++++
 .../test/resources/sql/supported/dml/insert.xml    |  1 +
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDMLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDMLVisitor.java
index a2f1371..6b08b65 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDMLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDMLVisitor.java
@@ -192,7 +192,6 @@ public final class MySQLDMLVisitor extends MySQLVisitor 
implements DMLVisitor {
         Collection<AssignmentSegment> columns = new LinkedList<>();
         for (AssignmentContext each : ctx.assignment()) {
             columns.add((AssignmentSegment) visit(each));
-            visit(each.assignmentValue());
         }
         return new 
OnDuplicateKeyColumnsSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex(), columns);
     }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/insert.xml
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/insert.xml
index 4fbb00c..0540692 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/insert.xml
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/case/dml/insert.xml
@@ -474,6 +474,40 @@
         </on-duplicate-key-columns>
     </insert>
 
+    <insert sql-case-id="insert_on_duplicate_key_update_with_placeholders" 
parameters="1, 1, 'init', 'init'">
+        <table name="t_order" start-index="12" stop-index="18" />
+        <columns start-index="20" stop-index="46">
+            <column name="order_id" start-index="21" stop-index="28" />
+            <column name="user_id" start-index="31" stop-index="37" />
+            <column name="status" start-index="40" stop-index="45" />
+        </columns>
+        <values>
+            <value>
+                <assignment-value>
+                    <parameter-marker-expression value="0" start-index="56" 
stop-index="56" />
+                    <literal-expression value="1" start-index="56" 
stop-index="56" />
+                </assignment-value>
+                <assignment-value>
+                    <parameter-marker-expression value="1" start-index="59" 
stop-index="59" />
+                    <literal-expression value="1" start-index="59" 
stop-index="59" />
+                </assignment-value>
+                <assignment-value>
+                    <parameter-marker-expression value="2" start-index="62" 
stop-index="62" />
+                    <literal-expression value="init" start-index="62" 
stop-index="67" />
+                </assignment-value>
+            </value>
+        </values>
+        <on-duplicate-key-columns start-index="65" stop-index="98" 
literal-start-index="70" literal-stop-index="108">
+            <assignment start-index="89" stop-index="98" 
literal-start-index="94" literal-stop-index="108">
+                <column name="status" start-index="89" stop-index="94" 
literal-start-index="94" literal-stop-index="99" />
+                <assignment-value>
+                    <parameter-marker-expression value="3" start-index="98" 
stop-index="98" />
+                    <literal-expression value="init" start-index="103" 
stop-index="108" />
+                </assignment-value>
+            </assignment>
+        </on-duplicate-key-columns>
+    </insert>
+
     <insert 
sql-case-id="insert_set_with_all_placeholders_for_table_identifier" 
parameters="1, 1, 'init'">
         <table name="t_order" start-index="12" stop-index="18" />
         <set start-index="20" stop-index="84" literal-stop-index="89">
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/insert.xml
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/insert.xml
index 3f73801..6a75888 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/insert.xml
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/supported/dml/insert.xml
@@ -40,6 +40,7 @@
     <sql-case id="insert_with_batch_and_with_generate_key_column" 
value="INSERT INTO t_order_item(item_id, order_id, user_id, status, 
creation_date) values (?, ?, ?, 'insert', '2017-08-08'), (?, ?, ?, 'insert', 
'2017-08-08')" />
     <sql-case id="insert_with_batch_and_without_generate_key_column" 
value="INSERT INTO t_order_item(order_id, user_id, status, creation_date) 
values (?, ?, 'insert', '2017-08-08'), (?, ?, 'insert', '2017-08-08')" />
     <sql-case id="insert_on_duplicate_key_update" value="INSERT INTO t_order 
(order_id, user_id, status) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE status = 
VALUES(status)" db-types="MySQL" />
+    <sql-case id="insert_on_duplicate_key_update_with_placeholders" 
value="INSERT INTO t_order (order_id, user_id, status) VALUES (?, ?, ?) ON 
DUPLICATE KEY UPDATE status = ?" db-types="MySQL" />
     <sql-case id="insert_on_duplicate_key_update_with_complicated_expression" 
value="INSERT INTO emp(order_id,emp_id,age,salary) VALUES (?,?,?,?) ON 
DUPLICATE KEY UPDATE salary = VALUES(salary)+VALUES(salary)*0.2" 
db-types="MySQL"/>
     <sql-case id="insert_with_multiple_values" value="INSERT INTO t_order 
(order_id, user_id, status) VALUES (1, 1, 'insert'), (2, 2, 'insert2')" 
db-types="MySQL" />
     <sql-case id="insert_on_duplicate_key_update_with_table_identifier" 
value="INSERT INTO t_order (t_order.order_id, t_order.user_id, t_order.status) 
VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE t_order.status = 
VALUES(t_order.status)" db-types="MySQL" />

Reply via email to