mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql wall
This commit is contained in:
+6
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.mysql.visitor;
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -46,7 +47,10 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
|
||||
public MySqlParameterizedOutputVisitor(Appendable appender){
|
||||
super(appender);
|
||||
|
||||
configFromPropety(System.getProperties());
|
||||
try {
|
||||
configFromPropety(System.getProperties());
|
||||
} catch (AccessControlException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void configFromPropety(Properties properties) {
|
||||
@@ -87,7 +91,7 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
|
||||
SQLObject parent = x.getParent();
|
||||
computeSharding = parent instanceof SQLExprTableSource || parent instanceof SQLPropertyExpr;
|
||||
}
|
||||
|
||||
|
||||
if (computeSharding) {
|
||||
int pos = name.lastIndexOf('_');
|
||||
if (pos != -1 && pos != name.length() - 1) {
|
||||
|
||||
@@ -94,7 +94,6 @@ import com.alibaba.druid.util.JdbcUtils;
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallConditionContext;
|
||||
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallSelectQueryContext;
|
||||
|
||||
public class SQLEvalVisitorUtils {
|
||||
|
||||
@@ -872,17 +871,14 @@ public class SQLEvalVisitorUtils {
|
||||
|
||||
if (x.getOperator() == SQLBinaryOperator.Like) {
|
||||
if (isAlwayTrueLikePattern(x.getRight())) {
|
||||
final WallSelectQueryContext wallSelectQueryContext = WallVisitorUtils.getWallSelectQueryContext();
|
||||
if (wallSelectQueryContext != null) {
|
||||
wallSelectQueryContext.setTrueLike(Boolean.TRUE);
|
||||
}
|
||||
x.putAttribute(WallVisitorUtils.HAS_TRUE_LIKE, Boolean.TRUE);
|
||||
x.putAttribute(EVAL_VALUE, Boolean.TRUE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getOperator() == SQLBinaryOperator.NotLike) {
|
||||
if (isAlwayTrueLikePattern(x)) {
|
||||
if (isAlwayTrueLikePattern(x.getRight())) {
|
||||
x.putAttribute(EVAL_VALUE, Boolean.FALSE);
|
||||
return false;
|
||||
}
|
||||
@@ -1063,7 +1059,7 @@ public class SQLEvalVisitorUtils {
|
||||
if (x instanceof SQLCharExpr) {
|
||||
String text = ((SQLCharExpr) x).getText();
|
||||
|
||||
if (text.length() >= 0) {
|
||||
if (text.length() > 0) {
|
||||
for (char ch : text.toCharArray()) {
|
||||
if (ch != '%') {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user