You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
m := g.DB().Model("information_schema.tables").Safe(false)
m = m.Where("table_schema = database()")
m = m.WhereNotLike("table_name", "sys_gen_%")
m = m.WhereNotIn("table_name", "(select table_name from sys_gen_table)")
if req.TableName != "" {
m = m.WhereLike("table_name", "%"+req.TableName+"%")
}
if req.TableComment != "" {
m = m.WhereLike("table_comment", "%"+req.TableComment+"%")
}
if len(req.DateRange) >= 2 {
m = m.WhereBetween("create_time", req.DateRange[0], req.DateRange[1])
}
err = g.Try(ctx, func(ctx context.Context) {
res.Total, err = m.Count()
libErr.ErrIsNil(ctx, err, "获取列表失败")
err = m.Page(req.PageNum, req.PageSize).Scan(&res.Tables)
libErr.ErrIsNil(ctx, err, "获取列表失败")
})
会报以下错误
2025-05-23T10:00:32.465+08:00 [ERRO] {3881084a7b0542189423b14f546d90b0} [ 10 ms] [default] [goframe_admin_dev] [rows:0 ] SHOW FULL COLUMNS FROM tables
Error: Error 1146 (42S02): Table 'goframe_admin_dev.tables' doesn't exist
Stack:
Issues-translate-bot
changed the title
gf model层操作 mysql的information_schema.tables 相关问题
gf model layer operation mysql's information_schema.tables related issues
May 23, 2025
What do you want to ask?
m := g.DB().Model("information_schema.tables").Safe(false)
m = m.Where("table_schema = database()")
m = m.WhereNotLike("table_name", "sys_gen_%")
m = m.WhereNotIn("table_name", "(select table_name from sys_gen_table)")
if req.TableName != "" {
m = m.WhereLike("table_name", "%"+req.TableName+"%")
}
if req.TableComment != "" {
m = m.WhereLike("table_comment", "%"+req.TableComment+"%")
}
if len(req.DateRange) >= 2 {
m = m.WhereBetween("create_time", req.DateRange[0], req.DateRange[1])
}
err = g.Try(ctx, func(ctx context.Context) {
res.Total, err = m.Count()
libErr.ErrIsNil(ctx, err, "获取列表失败")
err = m.Page(req.PageNum, req.PageSize).Scan(&res.Tables)
libErr.ErrIsNil(ctx, err, "获取列表失败")
})
会报以下错误
2025-05-23T10:00:32.465+08:00 [ERRO] {3881084a7b0542189423b14f546d90b0} [ 10 ms] [default] [goframe_admin_dev] [rows:0 ] SHOW FULL COLUMNS FROM
tables
Error: Error 1146 (42S02): Table 'goframe_admin_dev.tables' doesn't exist
Stack:
G:/goframe/gf/database/gdb/gdb_core.go:718
G:/goframe/gf/database/gdb/gdb_core_underlying.go:297
G:/goframe/gf/database/gdb/gdb_core_underlying.go:73
G:/goframe/gf/database/gdb/gdb_core.go:160
G:/goframe/gf/contrib/drivers/mysql/mysql_table_fields.go:77
G:/goframe/gf/database/gdb/gdb_driver_wrapper_db.go:81
G:/goframe/gf/os/gcache/gcache_adapter_memory_data.go:199
G:/goframe/gf/os/gcache/gcache_adapter_memory.go:387
G:/goframe/gf/os/gcache/gcache_adapter_memory.go:260
G:/goframe/gf/database/gdb/gdb_driver_wrapper_db.go:88
G:/goframe/gf/database/gdb/gdb_model_utility.go:49
G:/goframe/gf/database/gdb/gdb_model_utility.go:78
G:/goframe/gf/database/gdb/gdb_model_fields.go:251
G:/goframe/gf/database/gdb/gdb_model_fields.go:31
G:/goframe/gf/database/gdb/gdb_model_select.go:242
G:/goframe/gf/database/gdb/gdb_model_select.go:290
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:59
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/frame/g/g_func.go:87
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:56
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/frame/g/g_func.go:87
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:33
G:/goframe_admin/internal/controller/gen_table/gen_table_v1_get_list.go:11
G:/goframe/gf/net/ghttp/ghttp_server_service_handler.go:266
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:130
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:129
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:75
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:72
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:46
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/sys_token/token.go:350
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_middleware_handler_response.go:37
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:28
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_middleware_tracing.go:74
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:96
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:95
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_server_handler.go:88
2025-05-23T10:00:32.481+08:00 [ERRO] {64a3094b7b0542189523b14f734af9c8} [ 10 ms] [default] [goframe_admin_dev] [rows:0 ] SHOW FULL COLUMNS FROM
tables
Error: Error 1146 (42S02): Table 'goframe_admin_dev.tables' doesn't exist
Stack:
G:/goframe/gf/database/gdb/gdb_core.go:718
G:/goframe/gf/database/gdb/gdb_core_underlying.go:297
G:/goframe/gf/database/gdb/gdb_core_underlying.go:73
G:/goframe/gf/database/gdb/gdb_core.go:160
G:/goframe/gf/contrib/drivers/mysql/mysql_table_fields.go:77
G:/goframe/gf/database/gdb/gdb_driver_wrapper_db.go:81
G:/goframe/gf/os/gcache/gcache_adapter_memory_data.go:199
G:/goframe/gf/os/gcache/gcache_adapter_memory.go:387
G:/goframe/gf/os/gcache/gcache_adapter_memory.go:260
G:/goframe/gf/database/gdb/gdb_driver_wrapper_db.go:88
G:/goframe/gf/database/gdb/gdb_model_utility.go:49
G:/goframe/gf/database/gdb/gdb_model_soft_time.go:200
G:/goframe/gf/os/gcache/gcache_adapter_memory.go:231
G:/goframe/gf/database/gdb/gdb_model_soft_time.go:223
G:/goframe/gf/database/gdb/gdb_model_soft_time.go:181
G:/goframe/gf/database/gdb/gdb_model_soft_time.go:287
G:/goframe/gf/database/gdb/gdb_model_select.go:851
G:/goframe/gf/database/gdb/gdb_model_select.go:724
G:/goframe/gf/database/gdb/gdb_model_select.go:666
G:/goframe/gf/database/gdb/gdb_model_select.go:31
G:/goframe/gf/database/gdb/gdb_model_select.go:249
G:/goframe/gf/database/gdb/gdb_model_select.go:290
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:59
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/frame/g/g_func.go:87
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:56
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/frame/g/g_func.go:87
G:/goframe_admin/internal/logic/sys_gen_table/sys_gen_table.go:33
G:/goframe_admin/internal/controller/gen_table/gen_table_v1_get_list.go:11
G:/goframe/gf/net/ghttp/ghttp_server_service_handler.go:266
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:130
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:129
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:75
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:72
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:46
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/sys_token/token.go:350
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_middleware_handler_response.go:37
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe_admin/internal/logic/middleware/middleware.go:28
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:55
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:54
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_middleware_tracing.go:74
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:96
G:/goframe/gf/net/ghttp/ghttp_func.go:61
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:95
G:/goframe/gf/util/gutil/gutil_try_catch.go:36
G:/goframe/gf/util/gutil/gutil_try_catch.go:49
G:/goframe/gf/net/ghttp/ghttp_request_middleware.go:49
G:/goframe/gf/net/ghttp/ghttp_server_handler.go:88
请问一下 正确的操作是怎么样的
The text was updated successfully, but these errors were encountered: