提交 5a43f433 编写于 作者: T terrymanu

refactor remove unnecessary `not in` operator

上级 55126fe9
metrics_enable=true
dbtbl_0.driver=org.h2.Driver
dbtbl_0.url=jdbc:h2:mem:dbtbl_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_0.username=sa
......@@ -9,3 +7,5 @@ dbtbl_1.driver=org.h2.Driver
dbtbl_1.url=jdbc:h2:mem:dbtbl_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1.username=sa
dbtbl_1.password=
metrics_enable=true
......@@ -60,7 +60,6 @@ public final class ShardingProperties {
}
if (type == long.class && !StringUtil.isLongValue(value)) {
errorMessages.add(getErrorMessage(shardingPropertiesConstant, value));
continue;
}
}
if (!errorMessages.isEmpty()) {
......
......@@ -66,7 +66,7 @@ public final class Condition {
@RequiredArgsConstructor
public enum BinaryOperator {
EQUAL("="), BETWEEN("BETWEEN"), IN("IN"), NOT_IN("NOT IN");
EQUAL("="), BETWEEN("BETWEEN"), IN("IN");
@Getter
private final String expression;
......
......@@ -155,7 +155,9 @@ public abstract class AbstractMySQLVisitor extends MySqlOutputVisitor implements
@Override
public boolean visit(final SQLInListExpr x) {
parseContext.addCondition(x.getExpr(), x.isNot() ? BinaryOperator.NOT_IN : BinaryOperator.IN, x.getTargetList(), getDatabaseType(), getParameters());
if (!x.isNot()) {
parseContext.addCondition(x.getExpr(), BinaryOperator.IN, x.getTargetList(), getDatabaseType(), getParameters());
}
return super.visit(x);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<asserts>
<assert id="assertSelectWithParameter" sql="select * from order where order_id not in (?,2,3) and other_state = 'RUNNING'" expected-sql="SELECT * FROM [Token(order)] WHERE order_id NOT IN (?, 2, 3) AND other_state = 'RUNNING'">
<assert id="assertSelectWithParameter" sql="select * from order where order_id in (?,2,3) and other_state = 'RUNNING'" expected-sql="SELECT * FROM [Token(order)] WHERE order_id IN (?, 2, 3) AND other_state = 'RUNNING'">
<tables>
<table name="order" />
</tables>
<condition-contexts>
<condition-context>
<condition column-name="order_id" table-name="order" operator="NOT_IN">
<condition column-name="order_id" table-name="order" operator="IN">
<value value="1" type="int" />
<value value="2" type="int" />
<value value="3" type="int" />
......
......@@ -93,21 +93,6 @@
</condition-contexts>
</assert>
<assert id="assertSelectForNotIn" sql="select * from order where order_id not in (1,2,3) and other_state = 'RUNNING'" expected-sql="SELECT * FROM [Token(order)] WHERE order_id NOT IN (1, 2, 3) AND other_state = 'RUNNING'">
<tables>
<table name="order" />
</tables>
<condition-contexts>
<condition-context>
<condition column-name="order_id" table-name="order" operator="NOT_IN">
<value value="1" type="int" />
<value value="2" type="int" />
<value value="3" type="int" />
</condition>
</condition-context>
</condition-contexts>
</assert>
<assert id="assertSelectWithDateFunction" sql="select * from order where date = str_to_date('2013-01-01 01:21:01','%Y-%m-%d %H:%i:%s')" expected-sql="SELECT * FROM [Token(order)] WHERE date = str_to_date('2013-01-01 01:21:01', '%Y-%m-%d %H:%i:%s')">
<tables>
<table name="order" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册