diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/db/update_with_column_equal_column.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/db/update_with_column_equal_column.xml new file mode 100644 index 0000000000000000000000000000000000000000..eefca4b6b5052250612ae1802e962fbaa90826d8 --- /dev/null +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/db/update_with_column_equal_column.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/update_with_column_equal_column.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/update_with_column_equal_column.xml new file mode 100644 index 0000000000000000000000000000000000000000..4cbdd0787455e5e81529dce931ad9be99339cacf --- /dev/null +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/dbtbl_with_masterslave/update_with_column_equal_column.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/masterslave/update_with_column_equal_column.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/masterslave/update_with_column_equal_column.xml new file mode 100644 index 0000000000000000000000000000000000000000..9123f4a885544aa4ce02f738f3cac4c959eeb43c --- /dev/null +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/masterslave/update_with_column_equal_column.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/shadow/update_with_column_equal_column.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/shadow/update_with_column_equal_column.xml new file mode 100644 index 0000000000000000000000000000000000000000..a4f49967161d55b1e7713d9994c764e9605352b0 --- /dev/null +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/shadow/update_with_column_equal_column.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/tbl/update_with_column_equal_column.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/tbl/update_with_column_equal_column.xml new file mode 100644 index 0000000000000000000000000000000000000000..825573d179cc62cc2ef3ee584bc247e587c3b99a --- /dev/null +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dataset/tbl/update_with_column_equal_column.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml index 7b32fccc867054a4d8a28ba657cf680d7d2a6690..7a2b6202ca1cc348f464a03c53f08b21b24b7f6d 100644 --- a/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml +++ b/sharding-integration-test/sharding-jdbc-test/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml @@ -157,6 +157,10 @@ + + + + diff --git a/sharding-sql-test/src/main/resources/sql/supported/dml/update.xml b/sharding-sql-test/src/main/resources/sql/supported/dml/update.xml index 7500011b9edc69147eb64363051d3ee3396245a4..700d0b19a7d262859068c9e865ff4a2c8e720d02 100644 --- a/sharding-sql-test/src/main/resources/sql/supported/dml/update.xml +++ b/sharding-sql-test/src/main/resources/sql/supported/dml/update.xml @@ -26,4 +26,5 @@ + 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 20f05d321e06409e56a52b899accc7a86d208ddd..23b3973ac084dc9a28bfd9f679d26471b49ae2f3 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 @@ -247,7 +247,12 @@ public final class MySQLDMLVisitor extends MySQLVisitor implements DMLVisitor { public ASTNode visitAssignmentValue(final AssignmentValueContext ctx) { ExprContext expr = ctx.expr(); if (null != expr) { - return visit(expr); + ASTNode result = visit(expr); + if (result instanceof ColumnSegment) { + return new CommonExpressionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.getText()); + } else { + return result; + } } return new CommonExpressionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.getText()); } diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml/update.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml/update.xml index 1cb1a80134b0d267cf5f2f7d175af76f864bd418..27c1c674c7dd8302db5fb8e77d2d5629862fda14 100644 --- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml/update.xml +++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/test/resources/sql/dml/update.xml @@ -347,4 +347,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +