diff --git a/database/gdb/gdb_z_mysql_ctx_test.go b/database/gdb/gdb_z_mysql_ctx_test.go index 1853dbf69..7fa004f9b 100644 --- a/database/gdb/gdb_z_mysql_ctx_test.go +++ b/database/gdb/gdb_z_mysql_ctx_test.go @@ -38,4 +38,27 @@ func Test_Ctx_Query(t *testing.T) { ctx = context.WithValue(ctx, "SpanId", "0.1") db.Ctx(ctx).Query("select 1") }) + gtest.C(t, func(t *gtest.T) { + db.SetDebug(true) + defer db.SetDebug(false) + db.Query("select 2") + }) +} + +func Test_Ctx_Model(t *testing.T) { + table := createInitTable() + defer dropTable(table) + db.GetLogger().SetCtxKeys("SpanId", "TraceId") + gtest.C(t, func(t *gtest.T) { + db.SetDebug(true) + defer db.SetDebug(false) + ctx := context.WithValue(context.Background(), "TraceId", "12345678") + ctx = context.WithValue(ctx, "SpanId", "0.1") + db.Model(table).Ctx(ctx).All() + }) + gtest.C(t, func(t *gtest.T) { + db.SetDebug(true) + defer db.SetDebug(false) + db.Model(table).All() + }) }