diff --git a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/AbstractMySQLVisitor.java b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/AbstractMySQLVisitor.java index 0445e280b52968..fe4acc31ad3105 100644 --- a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/AbstractMySQLVisitor.java +++ b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/AbstractMySQLVisitor.java @@ -108,6 +108,9 @@ public final boolean visit(final SQLVariantRefExpr x) { @Override public final boolean visit(final SQLExprTableSource x) { + if ("dual".equalsIgnoreCase(SQLUtil.getExactlyValue(x.getExpr().toString()))) { + return super.visit(x); + } return visit(x, getParseContext().addTable(x)); } diff --git a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/MySQLInsertVisitor.java b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/MySQLInsertVisitor.java index ea54903aa6d38a..4b6b044253bc58 100644 --- a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/MySQLInsertVisitor.java +++ b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parser/visitor/basic/mysql/MySQLInsertVisitor.java @@ -32,6 +32,9 @@ public class MySQLInsertVisitor extends AbstractMySQLVisitor { @Override public boolean visit(final MySqlInsertStatement x) { getParseContext().setCurrentTable(x.getTableName().toString(), Optional.fromNullable(x.getAlias())); + if (null == x.getValues()) { + return super.visit(x); + } for (int i = 0; i < x.getColumns().size(); i++) { getParseContext().addCondition(x.getColumns().get(i).toString(), x.getTableName().toString(), BinaryOperator.EQUAL, x.getValues().getValues().get(i), getDatabaseType(), getParameters()); } diff --git a/sharding-jdbc-core/src/test/resources/com/dangdang/ddframe/rdb/sharding/parser/mysql/statement/insert.xml b/sharding-jdbc-core/src/test/resources/com/dangdang/ddframe/rdb/sharding/parser/mysql/statement/insert.xml index 7accb08dd7fb1b..d7ff12783e96b3 100644 --- a/sharding-jdbc-core/src/test/resources/com/dangdang/ddframe/rdb/sharding/parser/mysql/statement/insert.xml +++ b/sharding-jdbc-core/src/test/resources/com/dangdang/ddframe/rdb/sharding/parser/mysql/statement/insert.xml @@ -47,4 +47,13 @@ + + + + + + + + + diff --git a/sharding-jdbc-doc/content/post/release_notes.md b/sharding-jdbc-doc/content/post/release_notes.md index 4e132060b8cdc6..2a6312234195e9 100644 --- a/sharding-jdbc-doc/content/post/release_notes.md +++ b/sharding-jdbc-doc/content/post/release_notes.md @@ -15,6 +15,7 @@ weight = 1 ### 功能提升 1. [ISSUE #66](https://github.com/dangdangdotcom/sharding-jdbc/issues/66) 在JDBC层的Statement增加对get/set MaxFieldSize,MaxRows和QueryTimeout的支持 +1. [ISSUE #71](https://github.com/dangdangdotcom/sharding-jdbc/issues/71) 对于select union all形式的批量插入支持 ### 缺陷修正