|
@@ -16,7 +16,7 @@ public class PageSqlUtils {
|
|
|
private static final String OFFSET_PLACEHOLDER = "#{offset}";
|
|
|
|
|
|
// select 正则
|
|
|
- private static final String SQL_SELECT_PATTERN = "(select|SELECT).*?(?=from|FROM)";
|
|
|
+ private static final String SQL_SELECT_PATTERN = "(select|SELECT).*?(?=from\\s|FROM\\s)";
|
|
|
|
|
|
// order by 正则
|
|
|
private static final String SQL_ORDER_PATTERN = "(order|ORDER)\\s+(by|BY)";
|
|
@@ -70,7 +70,7 @@ public class PageSqlUtils {
|
|
|
|
|
|
|
|
|
/* 样例1 */
|
|
|
- String sql = "select a.* from audited_policy a where 1=1 \n\t \n\t \n\t \n\t \n\t and title like CONCAT('%',?,'%') \n\t \n\t \n\t \n\t \n\t \n\t \n\t \n\t \n\t order by updated_at desc";
|
|
|
+ String sql = "select a.*,from_1 from\naudited_policy a where 1=1 \n\t \n\t \n\t \n\t \n\t and title like CONCAT('%',?,'%') \n\t \n\t \n\t \n\t \n\t \n\t \n\t \n\t \n\t order by updated_at desc";
|
|
|
|
|
|
System.out.println(">>>>" + getCountSql(sql));
|
|
|
System.out.println(">>>>" + getLimitSQL(DbType.MYSQL, sql, new PageParams()));
|
|
@@ -84,8 +84,8 @@ public class PageSqlUtils {
|
|
|
System.out.println(">>>>" + getLimitSQL(DbType.MYSQL, sql, new PageParams()));
|
|
|
|
|
|
/* 样例3 */
|
|
|
- sql = "SELECT u.id as userId,u.name,u.cert_no as idcard,u.mobile,u.verified as userVerified,u.cert_front_url certFrontUrl,u.cert_back_url certBackUrl, o.salary,o.notax as afterTaxSalary,o.vattax as vatax,o.extratax as surtax,o.incometax,o.tax,o.invfphm as invoiceNo FROM cbd_invorderdet";
|
|
|
+ sql = "SELECT from_1,u.id as userId,u.name,u.cert_no as idcard,u.mobile,u.verified as userVerified,u.cert_front_url certFrontUrl,u.cert_back_url certBackUrl, o.salary,o.notax as afterTaxSalary,o.vattax as vatax,o.extratax as surtax,o.incometax,o.tax,o.invfphm as invoiceNo FROM cbd_invorderdet";
|
|
|
|
|
|
- System.out.println(sql.replaceAll("(select|SELECT).*?(?=from|FROM)", SQL_COUNT_PREFIX));
|
|
|
+ System.out.println(sql.replaceAll("(select|SELECT).*?(?=from\\s|FROM\\s)", SQL_COUNT_PREFIX));
|
|
|
}
|
|
|
}
|