|
@@ -77,8 +77,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
* <p>5.where条件使用了 not 关键字</p>
|
|
* <p>5.where条件使用了 not 关键字</p>
|
|
* <p>6.where条件使用了 or 关键字</p>
|
|
* <p>6.where条件使用了 or 关键字</p>
|
|
* <p>7.where条件使用了 使用子查询</p>
|
|
* <p>7.where条件使用了 使用子查询</p>
|
|
|
|
+ *
|
|
* @author willenfoo
|
|
* @author willenfoo
|
|
- * @date 2018-03-22
|
|
|
|
|
|
+ * @since 2018-03-22
|
|
*/
|
|
*/
|
|
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
|
|
@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
|
|
public class IllegalSQLInterceptor implements Interceptor {
|
|
public class IllegalSQLInterceptor implements Interceptor {
|
|
@@ -135,8 +136,8 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
/**
|
|
/**
|
|
* 如果SQL用了 left Join,验证是否有or、not等等,并且验证是否使用了索引
|
|
* 如果SQL用了 left Join,验证是否有or、not等等,并且验证是否使用了索引
|
|
*
|
|
*
|
|
- * @param joins ignore
|
|
|
|
- * @param table ignore
|
|
|
|
|
|
+ * @param joins ignore
|
|
|
|
+ * @param table ignore
|
|
* @param connection ignore
|
|
* @param connection ignore
|
|
*/
|
|
*/
|
|
private static void validJoins(List<Join> joins, Table table, Connection connection) {
|
|
private static void validJoins(List<Join> joins, Table table, Connection connection) {
|
|
@@ -153,7 +154,7 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
/**
|
|
/**
|
|
* 检查是否使用索引
|
|
* 检查是否使用索引
|
|
*
|
|
*
|
|
- * @param table ignore
|
|
|
|
|
|
+ * @param table ignore
|
|
* @param columnName ignore
|
|
* @param columnName ignore
|
|
* @param connection ignore
|
|
* @param connection ignore
|
|
*/
|
|
*/
|
|
@@ -188,7 +189,7 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
* 验证where条件的字段,是否有not、or等等,并且where的第一个字段,必须使用索引
|
|
* 验证where条件的字段,是否有not、or等等,并且where的第一个字段,必须使用索引
|
|
*
|
|
*
|
|
* @param expression ignore
|
|
* @param expression ignore
|
|
- * @param table ignore
|
|
|
|
|
|
+ * @param table ignore
|
|
* @param connection ignore
|
|
* @param connection ignore
|
|
*/
|
|
*/
|
|
private static void validWhere(Expression expression, Table table, Connection connection) {
|
|
private static void validWhere(Expression expression, Table table, Connection connection) {
|
|
@@ -199,8 +200,8 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
* 验证where条件的字段,是否有not、or等等,并且where的第一个字段,必须使用索引
|
|
* 验证where条件的字段,是否有not、or等等,并且where的第一个字段,必须使用索引
|
|
*
|
|
*
|
|
* @param expression ignore
|
|
* @param expression ignore
|
|
- * @param table ignore
|
|
|
|
- * @param joinTable ignore
|
|
|
|
|
|
+ * @param table ignore
|
|
|
|
+ * @param joinTable ignore
|
|
* @param connection ignore
|
|
* @param connection ignore
|
|
*/
|
|
*/
|
|
private static void validWhere(Expression expression, Table table, Table joinTable, Connection connection) {
|
|
private static void validWhere(Expression expression, Table table, Table joinTable, Connection connection) {
|
|
@@ -240,9 +241,9 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
/**
|
|
/**
|
|
* 得到表的索引信息
|
|
* 得到表的索引信息
|
|
*
|
|
*
|
|
- * @param dbName ignore
|
|
|
|
|
|
+ * @param dbName ignore
|
|
* @param tableName ignore
|
|
* @param tableName ignore
|
|
- * @param conn ignore
|
|
|
|
|
|
+ * @param conn ignore
|
|
* @return ignore
|
|
* @return ignore
|
|
*/
|
|
*/
|
|
public static List<IndexInfo> getIndexInfos(String dbName, String tableName, Connection conn) {
|
|
public static List<IndexInfo> getIndexInfos(String dbName, String tableName, Connection conn) {
|
|
@@ -252,10 +253,10 @@ public class IllegalSQLInterceptor implements Interceptor {
|
|
/**
|
|
/**
|
|
* 得到表的索引信息
|
|
* 得到表的索引信息
|
|
*
|
|
*
|
|
- * @param key ignore
|
|
|
|
- * @param dbName ignore
|
|
|
|
|
|
+ * @param key ignore
|
|
|
|
+ * @param dbName ignore
|
|
* @param tableName ignore
|
|
* @param tableName ignore
|
|
- * @param conn ignore
|
|
|
|
|
|
+ * @param conn ignore
|
|
* @return ignore
|
|
* @return ignore
|
|
*/
|
|
*/
|
|
public static List<IndexInfo> getIndexInfos(String key, String dbName, String tableName, Connection conn) {
|
|
public static List<IndexInfo> getIndexInfos(String key, String dbName, String tableName, Connection conn) {
|