Skip to content

Commit

Permalink
sql长度超出1000时,截断
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Nov 5, 2023
1 parent 19d43e2 commit 8b51351
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion traceDetailDatabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ func (receiver *TraceDetailDatabase) GetTraceDetail() *trace.BaseTraceDetail {

func (receiver *TraceDetailDatabase) ToString() string {
if receiver.Sql != "" {
sql := flog.ReplaceBlues(receiver.Sql, "SELECT ", "UPDATE ", "DELETE ", "INSERT INTO ", " FROM ", " WHERE ", " LIMIT ", " SET ", " ORDER BY ", " VALUES ", " and ", " or ")
sql := receiver.Sql
if len(sql) > 1000 {
sql = sql[:1000] + "......"
}
sql = flog.ReplaceBlues(sql, "SELECT ", "UPDATE ", "DELETE ", "INSERT INTO ", " FROM ", " WHERE ", " LIMIT ", " SET ", " ORDER BY ", " VALUES ", " and ", " or ", "`")
sql = strings.ReplaceAll(sql, receiver.TableName, flog.Green(receiver.TableName))
return fmt.Sprintf("[%s]耗时:%s,[影响%d行]%s", flog.Yellow(receiver.CallType.ToString()), flog.Red(receiver.UseTs.String()), receiver.RowsAffected, sql)
} else if receiver.ConnectionString != "" {
Expand Down

0 comments on commit 8b51351

Please sign in to comment.