Skip to content

Commit

Permalink
[fix] 修正慢SQL中Insert语句超长的bug,SQL日志最大长度重新恢复4096
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Mar 15, 2024
1 parent cbe7271 commit e96a94d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion XCode/DataAccessLayer/Common/DbSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ public void WriteSQL(String sql)
try
{
var sql = cmd.CommandText;
var isInsert = sql.StartsWithIgnoreCase("Insert");

// 诊断信息
/*if (XTrace.Log.Level <= LogLevel.Debug)*/
Expand Down Expand Up @@ -999,7 +1000,7 @@ public void WriteSQL(String sql)
// 截断超长字符串
if (max > 0 && sql.Length > max)
{
if (sql.StartsWithIgnoreCase("Insert")) sql = sql[..(max / 2)] + "..." + sql[^(max / 2)..];
if (isInsert) sql = sql[..(max / 2)] + "......" + sql[^(max / 2)..];
}

return sql;
Expand Down
6 changes: 3 additions & 3 deletions XCode/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class XCodeSetting : Config<XCodeSetting>
[Description("SQL执行时间。跟踪SQL执行时间,大于该阀值将输出日志,默认1000毫秒")]
public Int32 TraceSQLTime { get; set; } = 1000;

/// <summary>SQL最大长度,输出日志时的SQL最大长度,超长截断,默认1024,不截断用0</summary>
[Description("SQL最大长度。输出日志时的SQL最大长度,超长截断,默认1024,不截断用0")]
public Int32 SQLMaxLength { get; set; } = 1024;
/// <summary>SQL最大长度,输出日志时的SQL最大长度,超长截断,默认4096,不截断用0</summary>
[Description("SQL最大长度。输出日志时的SQL最大长度,超长截断,默认4096,不截断用0")]
public Int32 SQLMaxLength { get; set; } = 4096;

///// <summary>连接名映射#,表名映射@,表名映射@,把实体类中的Test2和Test3连接名映射到Test去</summary>
//[Description("连接映射。连接名映射#,表名映射@,把实体类中的Test2和Test3连接名映射到Test去")]
Expand Down

0 comments on commit e96a94d

Please sign in to comment.