diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 4009e251882a7..d4c651d7c7934 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -9,6 +9,7 @@ 1. [ISSUE #349](https://github.com/dangdangdotcom/sharding-jdbc/issues/349) ResultSet.wasNull功能不正确 1. [ISSUE #351](https://github.com/dangdangdotcom/sharding-jdbc/issues/351) 包含在默认数据源但不在TableRule配置的表无法正确执行 1. [ISSUE #353](https://github.com/dangdangdotcom/sharding-jdbc/issues/353) 在SQL的Where条件中兼容不是分片列的!=, !> 和 !< 操作符 +1. [ISSUE #354](https://github.com/dangdangdotcom/sharding-jdbc/issues/354) 在SQL的Where条件中兼容不是分片列的NOT操作符 ## 1.5.2 diff --git a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/clause/WhereClauseParser.java b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/clause/WhereClauseParser.java index 25de2dc796fb1..7c5050597ec7e 100644 --- a/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/clause/WhereClauseParser.java +++ b/sharding-jdbc-core/src/main/java/com/dangdang/ddframe/rdb/sharding/parsing/parser/clause/WhereClauseParser.java @@ -98,6 +98,12 @@ private void parseComparisonCondition(final ShardingRule shardingRule, final SQL if (lexerEngine.skipIfEqual(Symbol.LT, Symbol.LT_EQ, Symbol.GT, Symbol.GT_EQ, Symbol.LT_GT, Symbol.BANG_EQ, Symbol.BANG_GT, Symbol.BANG_LT, DefaultKeyword.LIKE)) { parseOtherCondition(sqlStatement); } + if (lexerEngine.skipIfEqual(DefaultKeyword.NOT)) { + lexerEngine.nextToken(); + lexerEngine.skipIfEqual(Symbol.LEFT_PAREN); + parseOtherCondition(sqlStatement); + lexerEngine.skipIfEqual(Symbol.RIGHT_PAREN); + } lexerEngine.skipIfEqual(Symbol.RIGHT_PAREN); } diff --git a/sharding-jdbc-core/src/test/resources/integrate/assert/select.xml b/sharding-jdbc-core/src/test/resources/integrate/assert/select.xml index e526bbbe9f415..aa97a64742633 100644 --- a/sharding-jdbc-core/src/test/resources/integrate/assert/select.xml +++ b/sharding-jdbc-core/src/test/resources/integrate/assert/select.xml @@ -15,6 +15,11 @@ + + + + + diff --git a/sharding-jdbc-core/src/test/resources/parser/select_expression.xml b/sharding-jdbc-core/src/test/resources/parser/select_expression.xml index 4ae54dd14ed13..f6b21a90af13b 100644 --- a/sharding-jdbc-core/src/test/resources/parser/select_expression.xml +++ b/sharding-jdbc-core/src/test/resources/parser/select_expression.xml @@ -32,6 +32,14 @@ + + + + + + + +
diff --git a/sharding-jdbc-core/src/test/resources/sql/dql/select_expression.xml b/sharding-jdbc-core/src/test/resources/sql/dql/select_expression.xml index cfc847dff7ccb..611632f49f17b 100644 --- a/sharding-jdbc-core/src/test/resources/sql/dql/select_expression.xml +++ b/sharding-jdbc-core/src/test/resources/sql/dql/select_expression.xml @@ -4,6 +4,7 @@ +