mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
remove show sql for group
This commit is contained in:
parent
5302edf980
commit
757bfdc723
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.7.2 (2021-06-16)
|
# 5.7.2 (2021-06-17)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 增加UserPassAuthenticator
|
* 【core 】 增加UserPassAuthenticator
|
||||||
|
* 【db 】 获取分组数据源时,移除公共属性项
|
||||||
|
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【db 】 修复Oracle下别名错误造成的SQL语法啊错误(issue#I3VTQW@Gitee)
|
* 【db 】 修复Oracle下别名错误造成的SQL语法啊错误(issue#I3VTQW@Gitee)
|
||||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.io.IoUtil;
|
|||||||
import cn.hutool.db.dialect.Dialect;
|
import cn.hutool.db.dialect.Dialect;
|
||||||
import cn.hutool.db.dialect.DialectFactory;
|
import cn.hutool.db.dialect.DialectFactory;
|
||||||
import cn.hutool.db.ds.DSFactory;
|
import cn.hutool.db.ds.DSFactory;
|
||||||
|
import cn.hutool.db.sql.SqlLog;
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
import cn.hutool.log.level.Level;
|
import cn.hutool.log.level.Level;
|
||||||
import cn.hutool.setting.Setting;
|
import cn.hutool.setting.Setting;
|
||||||
@ -168,17 +169,31 @@ public final class DbUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从配置文件中读取SQL打印选项
|
* 移除配置文件中的Show SQL相关配置项<br>
|
||||||
|
* 此方法用于移除用户配置在分组下的配置项目
|
||||||
|
*
|
||||||
|
* @param setting 配置项
|
||||||
|
* @since 5.7.2
|
||||||
|
*/
|
||||||
|
public static void removeShowSqlParams(Setting setting){
|
||||||
|
setting.remove(SqlLog.KEY_SHOW_SQL);
|
||||||
|
setting.remove(SqlLog.KEY_FORMAT_SQL);
|
||||||
|
setting.remove(SqlLog.KEY_SHOW_PARAMS);
|
||||||
|
setting.remove(SqlLog.KEY_SQL_LEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从配置文件中读取SQL打印选项,读取后会去除相应属性
|
||||||
*
|
*
|
||||||
* @param setting 配置文件
|
* @param setting 配置文件
|
||||||
* @since 4.1.7
|
* @since 4.1.7
|
||||||
*/
|
*/
|
||||||
public static void setShowSqlGlobal(Setting setting) {
|
public static void setShowSqlGlobal(Setting setting) {
|
||||||
// 初始化SQL显示
|
// 初始化SQL显示
|
||||||
final boolean isShowSql = Convert.toBool(setting.remove("showSql"), false);
|
final boolean isShowSql = Convert.toBool(setting.remove(SqlLog.KEY_SHOW_SQL), false);
|
||||||
final boolean isFormatSql = Convert.toBool(setting.remove("formatSql"), false);
|
final boolean isFormatSql = Convert.toBool(setting.remove(SqlLog.KEY_FORMAT_SQL), false);
|
||||||
final boolean isShowParams = Convert.toBool(setting.remove("showParams"), false);
|
final boolean isShowParams = Convert.toBool(setting.remove(SqlLog.KEY_SHOW_PARAMS), false);
|
||||||
String sqlLevelStr = setting.remove("sqlLevel");
|
String sqlLevelStr = setting.remove(SqlLog.KEY_SQL_LEVEL);
|
||||||
if (null != sqlLevelStr) {
|
if (null != sqlLevelStr) {
|
||||||
sqlLevelStr = sqlLevelStr.toUpperCase();
|
sqlLevelStr = sqlLevelStr.toUpperCase();
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,11 @@ public abstract class AbstractDSFactory extends DSFactory {
|
|||||||
if (StrUtil.isBlank(url)) {
|
if (StrUtil.isBlank(url)) {
|
||||||
throw new DbRuntimeException("No JDBC URL for group: [{}]", group);
|
throw new DbRuntimeException("No JDBC URL for group: [{}]", group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除用户可能误加入的show sql配置项
|
||||||
|
// issue#I3VW0R@Gitee
|
||||||
|
DbUtil.removeShowSqlParams(config);
|
||||||
|
|
||||||
// 自动识别Driver
|
// 自动识别Driver
|
||||||
String driver = config.getAndRemoveStr(KEY_ALIAS_DRIVER);
|
String driver = config.getAndRemoveStr(KEY_ALIAS_DRIVER);
|
||||||
if (StrUtil.isBlank(driver)) {
|
if (StrUtil.isBlank(driver)) {
|
||||||
|
@ -6,13 +6,30 @@ import cn.hutool.log.level.Level;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL在日志中打印配置
|
* SQL在日志中打印配置
|
||||||
*
|
*
|
||||||
* @author looly
|
* @author looly
|
||||||
* @since 4.1.0
|
* @since 4.1.0
|
||||||
*/
|
*/
|
||||||
public enum SqlLog {
|
public enum SqlLog {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置文件中配置属性名:是否显示SQL
|
||||||
|
*/
|
||||||
|
public static final String KEY_SHOW_SQL = "showSql";
|
||||||
|
/**
|
||||||
|
* 配置文件中配置属性名:是否格式化SQL
|
||||||
|
*/
|
||||||
|
public static final String KEY_FORMAT_SQL = "formatSql";
|
||||||
|
/**
|
||||||
|
* 配置文件中配置属性名:是否显示参数
|
||||||
|
*/
|
||||||
|
public static final String KEY_SHOW_PARAMS = "showParams";
|
||||||
|
/**
|
||||||
|
* 配置文件中配置属性名:显示的日志级别
|
||||||
|
*/
|
||||||
|
public static final String KEY_SQL_LEVEL = "sqlLevel";
|
||||||
|
|
||||||
private final static Log log = LogFactory.get();
|
private final static Log log = LogFactory.get();
|
||||||
|
|
||||||
/** 是否debugSQL */
|
/** 是否debugSQL */
|
||||||
@ -23,10 +40,10 @@ public enum SqlLog {
|
|||||||
private boolean showParams;
|
private boolean showParams;
|
||||||
/** 默认日志级别 */
|
/** 默认日志级别 */
|
||||||
private Level level = Level.DEBUG;
|
private Level level = Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置全局配置:是否通过debug日志显示SQL
|
* 设置全局配置:是否通过debug日志显示SQL
|
||||||
*
|
*
|
||||||
* @param isShowSql 是否显示SQL
|
* @param isShowSql 是否显示SQL
|
||||||
* @param isFormatSql 是否格式化显示的SQL
|
* @param isFormatSql 是否格式化显示的SQL
|
||||||
* @param isShowParams 是否打印参数
|
* @param isShowParams 是否打印参数
|
||||||
|
Loading…
x
Reference in New Issue
Block a user