diff --git a/database/gdb/gdb_z_mysql_model_test.go b/database/gdb/gdb_z_mysql_model_test.go index dc2cf59c2..66482520e 100644 --- a/database/gdb/gdb_z_mysql_model_test.go +++ b/database/gdb/gdb_z_mysql_model_test.go @@ -2159,13 +2159,17 @@ func Test_Model_FieldsEx(t *testing.T) { } func Test_Model_FieldsEx_WithReservedWords(t *testing.T) { - table := "fieldsex_test_table" - sqlTpcPath := gdebug.TestDataPath("reservedwords_table_tpl.sql") - if _, err := db.Exec(ctx, fmt.Sprintf(gfile.GetContents(sqlTpcPath), table)); err != nil { - gtest.Error(err) - } - defer dropTable(table) gtest.C(t, func(t *gtest.T) { + var ( + table = "fieldsex_test_table" + sqlTpcPath = gdebug.TestDataPath("reservedwords_table_tpl.sql") + sqlContent = gfile.GetContents(sqlTpcPath) + ) + t.AssertNE(sqlContent, "") + if _, err := db.Exec(ctx, fmt.Sprintf(sqlContent, table)); err != nil { + t.AssertNil(err) + } + defer dropTable(table) _, err := db.Model(table).FieldsEx("content").One() t.AssertNil(err) }) diff --git a/debug/gdebug/gdebug_caller.go b/debug/gdebug/gdebug_caller.go index 70bb1a28f..62133837a 100644 --- a/debug/gdebug/gdebug_caller.go +++ b/debug/gdebug/gdebug_caller.go @@ -14,8 +14,6 @@ import ( "reflect" "runtime" "strings" - - "github.com/gogf/gf/v2/internal/utils" ) const ( @@ -35,7 +33,7 @@ func init() { goRootForFilter = strings.Replace(goRootForFilter, "\\", "/", -1) } // Initialize internal package variable: selfPath. - selfPath, _ := exec.LookPath(os.Args[0]) + selfPath, _ = exec.LookPath(os.Args[0]) if selfPath != "" { selfPath, _ = filepath.Abs(selfPath) } @@ -69,7 +67,7 @@ func CallerWithFilter(filter string, skip ...int) (function string, path string, pc, file, line, ok = runtime.Caller(i) } if ok { - function := "" + function = "" if fn := runtime.FuncForPC(pc); fn == nil { function = "unknown" } else { @@ -102,14 +100,8 @@ func callerFromIndex(filters []string) (pc uintptr, file string, line int, index if filtered { continue } - if !utils.IsDebugEnabled() { - if strings.Contains(file, utils.StackFilterKeyForGoFrame) { - continue - } - } else { - if strings.Contains(file, stackFilterKey) { - continue - } + if strings.Contains(file, stackFilterKey) { + continue } if index > 0 { index-- diff --git a/debug/gdebug/gdebug_stack.go b/debug/gdebug/gdebug_stack.go index 2a70b542e..ffcfd7b6c 100644 --- a/debug/gdebug/gdebug_stack.go +++ b/debug/gdebug/gdebug_stack.go @@ -11,8 +11,6 @@ import ( "fmt" "runtime" "strings" - - "github.com/gogf/gf/v2/internal/utils" ) // PrintStack prints to standard error the stack trace returned by runtime.Stack. @@ -82,14 +80,8 @@ func StackWithFilters(filters []string, skip ...int) string { continue } - if !utils.IsDebugEnabled() { - if strings.Contains(file, utils.StackFilterKeyForGoFrame) { - continue - } - } else { - if strings.Contains(file, stackFilterKey) { - continue - } + if strings.Contains(file, stackFilterKey) { + continue } if fn := runtime.FuncForPC(pc); fn == nil { diff --git a/errors/gerror/gerror_error.go b/errors/gerror/gerror_error.go index 55111edab..e0f27bb4d 100644 --- a/errors/gerror/gerror_error.go +++ b/errors/gerror/gerror_error.go @@ -15,7 +15,6 @@ import ( "strings" "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/utils" ) // Error is custom error for additional features. @@ -201,14 +200,8 @@ func formatSubStack(st stack, buffer *bytes.Buffer) { if fn := runtime.FuncForPC(p - 1); fn != nil { file, line := fn.FileLine(p - 1) // Custom filtering. - if !utils.IsDebugEnabled() { - if strings.Contains(file, utils.StackFilterKeyForGoFrame) { - continue - } - } else { - if strings.Contains(file, stackFilterKeyLocal) { - continue - } + if strings.Contains(file, stackFilterKeyLocal) { + continue } // Avoid stack string like "`autogenerated`" if strings.Contains(file, "<") { diff --git a/internal/utils/utils_debug.go b/internal/utils/utils_debug.go index 6b46503bd..0b2fc17e6 100644 --- a/internal/utils/utils_debug.go +++ b/internal/utils/utils_debug.go @@ -16,7 +16,7 @@ const ( // StackFilterKeyForGoFrame is the stack filtering key for all GoFrame module paths. // Eg: .../pkg/mod/github.com/gogf/gf/v2@v2.0.0-20211011134327-54dd11f51122/debug/gdebug/gdebug_caller.go - StackFilterKeyForGoFrame = "github.com/gogf/gf/v" + StackFilterKeyForGoFrame = "github.com/gogf/gf/" ) var (