Skip to content

Commit

Permalink
Merge branch '5.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
chenrenfei committed Jul 12, 2024
2 parents 2af9001 + c2a0700 commit 71a82cd
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 52 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ https://github.com/sagframe/sqltoy-online-doc/blob/master/docs/sqltoy/search.md
# 码云地址: https://gitee.com/sagacity/sagacity-sqltoy

# 最新版本
* 5.6.10 LTS (jdk17+/springboot3.x)/5.6.10.jre8 (兼容5.2.x/5.3.x版本) 发版日期: 2024-5-27
* 5.6.11 LTS (jdk17+/springboot3.x)/5.6.11.jre8 (兼容5.2.x/5.3.x版本) 发版日期: 2024-7-12
```xml
<dependency>
<groupId>com.sagframe</groupId>
<artifactId>sagacity-sqltoy-spring-starter</artifactId>
<!-- solon 适配版本 <artifactId>sagacity-sqltoy-solon-plugin</artifactId> -->
<!-- jdk8 对应的版本号为:5.6.10.jre8 -->
<version>5.6.10</version>
<!-- jdk8 对应的版本号为:5.6.11.jre8 -->
<version>5.6.11</version>
</dependency>
```
* 5.2.105 LTS (jdk1.8+) 发版日期: 2024-6-6
Expand Down
2 changes: 1 addition & 1 deletion trunk/sqltoy-orm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.11.RC4</version>
<version>5.6.11</version>
<name>sagacity-sqltoy</name>
<description>sqltoy core code</description>
<artifactId>sagacity-sqltoy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.lang.System.out;

import java.lang.reflect.Proxy;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -327,6 +328,10 @@ public static String getFirstTrace() {
// 避免异常发生
if (i + 1 < length) {
traceElement = stackTraceElements[i + 1];
//判断是否代理类,是代理类继续向上推一层
if ((i + 2) < length && Proxy.isProxyClass(traceElement.getClass())) {
traceElement = stackTraceElements[i + 2];
}
className = traceElement.getClassName();
method = traceElement.getMethodName();
lineNumber = traceElement.getLineNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public static String mergeIgnore(IUnifyFieldsHandler unifyFieldsHandler, Integer
}

/**
* @TODO 针对postgresql\kingbase\guassdb等数据库
* @TODO 针对postgresql\kingbase\guassdb\mogdb等数据库
* @param unifyFieldsHandler
* @param dbType
* @param entityMeta
Expand All @@ -487,7 +487,8 @@ public static String insertIgnore(IUnifyFieldsHandler unifyFieldsHandler, Intege
StringBuilder values = new StringBuilder(columnSize * 2 - 1);
if (dbType == DBType.GAUSSDB) {
sql.append("insert ignore into ");
} else {
} // mogdb支持insert into do nothing
else {
sql.append("insert into ");
}
sql.append(entityMeta.getSchemaTable(tableName, dbType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ private static String replaceFunction(String sqlContent, int dbType, IFunction f
if (StringUtil.matches(functionParams, function.regex())) {
functionParams = replaceFunction(functionParams, dbType, function);
}
args = StringUtil.splitExcludeSymMark(functionParams, ",", SqlToyConstants.filters);
if (functionParams == null || functionParams.trim().equals("")) {
args = null;
} else {
args = StringUtil.splitExcludeSymMark(functionParams, ",", SqlToyConstants.filters);
}
} else {
args = null;
endMarkIndex = matcher.end() - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Concat extends IFunction {
*/
@Override
public String dialects() {
return "oracle";
return super.ALL;
}

/*
Expand All @@ -45,20 +45,20 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length < 3) {
return super.IGNORE;
}
// 只针对oracle数据库,其他数据库原样返回
if (dialect == DBType.ORACLE || dialect == DBType.OCEANBASE || dialect == DBType.DM
|| dialect == DBType.ORACLE11) {
// 超过2个参数
if (args != null && args.length > 2) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < args.length; i++) {
if (i > 0) {
result.append("||");
}
result.append(args[i].replace("\\'", "''"));
if (dialect == DBType.ORACLE || dialect == DBType.ORACLE11) {
// 超过2个参数(oracle 支持2个参数
StringBuilder result = new StringBuilder();
for (int i = 0; i < args.length; i++) {
if (i > 0) {
result.append("||");
}
return result.toString();
result.append(args[i].replace("\\'", "''"));
}
return result.toString();
}
return super.IGNORE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ConcatWs extends IFunction {
*/
@Override
public String dialects() {
return "oracle";
return super.ALL;
}

/*
Expand All @@ -45,12 +45,11 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args.length < 2) {
if (args == null || args.length < 2) {
return super.IGNORE;
}
// 只针对oracle数据库,其他数据库原样返回
if (dialect == DBType.ORACLE || dialect == DBType.OCEANBASE || dialect == DBType.DM
|| dialect == DBType.ORACLE11) {
// oracle 不支持concat_ws
if (dialect == DBType.ORACLE || dialect == DBType.ORACLE11) {
StringBuilder result = new StringBuilder();
String split = args[0].replace("\\'", "''");
for (int i = 1; i < args.length; i++) {
Expand All @@ -60,6 +59,13 @@ public String wrap(int dialect, String functionName, boolean hasArgs, String...
result.append(args[i].replace("\\'", "''"));
}
return result.toString();
} else if (dialect == DBType.DM) {
String splitStr = args[0].trim();
// dm concat_ws不支持双引号包装分割符号
if (splitStr.startsWith("\"") && splitStr.endsWith("\"")) {
args[0] = "'" + splitStr.substring(1, splitStr.length() - 1) + "'";
return wrapArgs("concat_ws", args);
}
}
return super.IGNORE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length < 2) {
return super.IGNORE;
}
String format;
switch (dialect) {
case DBType.POSTGRESQL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public String dialects() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length < 2) {
return super.IGNORE;
}
/*
* if (dialect == DBType.MYSQL || dialect == DBType.MYSQL8) { return
* wrapArgs("ELT", args); } else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
String[] realArgs;
String funLow = functionName.toLowerCase();
if ("position".equals(funLow)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
String funLow = functionName.toLowerCase();
if (dialect == DBType.SQLSERVER) {
if ("datalength".equals(funLow)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
String funLow = functionName.toLowerCase();
if (dialect == DBType.SQLSERVER) {
return wrapArgs("isnull", args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
if (dialect == DBType.POSTGRESQL || dialect == DBType.POSTGRESQL15 || dialect == DBType.GAUSSDB
|| dialect == DBType.MOGDB || dialect == DBType.SQLSERVER || dialect == DBType.H2) {
if (dialect == DBType.SQLSERVER && args != null && args.length == 2) {
if (dialect == DBType.SQLSERVER && args.length == 2) {
return "substring(" + args[0] + "," + args[1] + ",len(" + args[0] + "))";
}
return wrapArgs("substring", args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public String dialects() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args.length == 1) {
if (args == null || args.length < 2) {
return super.IGNORE;
}
String format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ToDate extends IFunction {

@Override
public String dialects() {
return "oracle,dm,mysql,sqlserver,h2";
return ALL;
}

/*
Expand All @@ -39,35 +39,34 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
if (dialect == DBType.SQLSERVER) {
if (args != null && args.length == 1) {
if (args.length == 1) {
if (args[0].length() > 12) {
return "convert(datetime," + args[0] + ")";
}
return "convert(date," + args[0] + ")";
}
}
if (dialect == DBType.ORACLE || dialect == DBType.ORACLE11) {
if (args != null) {
if (args.length > 1) {
return wrapArgs("to_date", args);
if (args.length > 1) {
return wrapArgs("to_date", args);
} else {
if (args[0].length() > 12) {
return "to_date(" + args[0] + ",'yyyy-MM-dd HH:mm:ss')";
} else {
if (args[0].length() > 12) {
return "to_date(" + args[0] + ",'yyyy-MM-dd HH:mm:ss')";
} else {
return "to_date(" + args[0] + ",'yyyy-MM-dd')";
}
return "to_date(" + args[0] + ",'yyyy-MM-dd')";
}
}
}
if (dialect == DBType.H2) {
if (args != null) {
if (args != null && args.length == 1) {
if (args[0].length() > 12) {
return "formatdatetime(" + args[0] + ",'yyyy-MM-dd HH:mm:ss')";
} else {
return "formatdatetime(" + args[0] + ",'yyyy-MM-dd')";
}
if (args.length == 1) {
if (args[0].length() > 12) {
return "formatdatetime(" + args[0] + ",'yyyy-MM-dd HH:mm:ss')";
} else {
return "formatdatetime(" + args[0] + ",'yyyy-MM-dd')";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Pattern regex() {

@Override
public String dialects() {
return "db2,oracle,dm";
return ALL;
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public Pattern regex() {
*/
@Override
public String wrap(int dialect, String functionName, boolean hasArgs, String... args) {
if (args == null || args.length == 0) {
return super.IGNORE;
}
if (dialect == DBType.SQLSERVER) {
return "rtrim(ltrim(" + args[0] + "))";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@ public static String clearMark(String sql) {
int markIndex = sql.indexOf("<!--");
while (markIndex != -1) {
endMarkIndex = sql.indexOf("-->", markIndex);
if (endMarkIndex == -1 || endMarkIndex == sql.length() - 3) {
// update 2024-7-8 兼容sql中存在<!-- 但没有-->收尾的情况
if (endMarkIndex == -1) {
break;
} else if (endMarkIndex == sql.length() - 3) {
sql = sql.substring(0, markIndex);
break;
} else {
Expand All @@ -761,7 +764,10 @@ public static String clearMark(String sql) {
markIndex = StringUtil.matchIndex(sql, maskPattern);
while (markIndex != -1) {
endMarkIndex = sql.indexOf("*/", markIndex);
if (endMarkIndex == -1 || endMarkIndex == sql.length() - 2) {
// update 2024-7-8 兼容sql中存在/* 但没有*/收尾的情况
if (endMarkIndex == -1) {
break;
} else if (endMarkIndex == sql.length() - 2) {
sql = sql.substring(0, markIndex);
break;
} else {
Expand Down
6 changes: 3 additions & 3 deletions trunk/sqltoy-orm-solon-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.sagframe</groupId>
<version>5.6.11.RC4</version>
<version>5.6.11</version>

<artifactId>sagacity-sqltoy-solon-plugin</artifactId>
<name>sagacity-sqltoy-solon-plugin</name>
Expand All @@ -16,8 +16,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<solon.version>2.8.4</solon.version>
<redisx.version>1.6.4</redisx.version>
<solon.version>2.8.5</solon.version>
<redisx.version>1.6.5</redisx.version>
<mongo.version>3.12.14</mongo.version>
<slf4j.version>2.0.13</slf4j.version>
<caffeine.version>3.1.8</caffeine.version>
Expand Down
2 changes: 1 addition & 1 deletion trunk/sqltoy-orm-spring-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.11.RC4</version>
<version>5.6.11</version>
<name>sagacity-sqltoy-spring-starter</name>
<artifactId>sagacity-sqltoy-spring-starter</artifactId>
<description>sqltoy springboot starter</description>
Expand Down
4 changes: 2 additions & 2 deletions trunk/sqltoy-orm-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagframe</groupId>
<version>5.6.11.RC4</version>
<version>5.6.11</version>
<name>sagacity-sqltoy-spring</name>
<description>sagacity-sqltoy-spring</description>
<artifactId>sagacity-sqltoy-spring</artifactId>
<url>https://github.com/sagframe/sagacity-sqltoy</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-framework.version>6.1.10</spring-framework.version>
<spring-framework.version>6.1.11</spring-framework.version>
<spring-data-commons.version>3.2.7</spring-data-commons.version>
<spring-data-redis.version>3.2.7</spring-data-redis.version>
<spring-data-mongo.version>4.2.7</spring-data-mongo.version>
Expand Down

0 comments on commit 71a82cd

Please sign in to comment.