fix🐛: db columns endpoint rejected exactly the valid requests

pkg.Assert panics when its condition is false, so
Assert(TableName == "", "table name cannot be empty") rejected every
request that carried a table name and let the empty one through. The
model layer repeated the inversion with if TableName != "" { return
error }, so either one alone was enough to break the endpoint.

Flip both, and hoist the model guard out of the mysql branch so it
matches GetList ten lines below, which had it right all along.
This commit is contained in:
zhangwenjian
2026-08-23 13:19:15 +08:00
parent f8f697af2b
commit d16f5e7180
3 changed files with 83 additions and 6 deletions
+4 -5
View File
@@ -28,14 +28,13 @@ func (e *DBColumns) GetPage(tx *gorm.DB, pageSize int, pageIndex int) ([]DBColum
var count int64
table := new(gorm.DB)
if e.TableName == "" {
return nil, 0, errors.New("table name cannot be empty")
}
if config.DatabaseConfig.Driver == "mysql" {
table = tx.Table("information_schema.`COLUMNS`")
table = table.Where("table_schema= ? ", config.GenConfig.DBName)
if e.TableName != "" {
return nil, 0, errors.New("table name cannot be empty")
}
table = table.Where("TABLE_NAME = ?", e.TableName)
}