mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-18 22:22:59 +08:00
fix: 修改远程数据库列表查询规则 (#2166)
This commit is contained in:
parent
ba38402a24
commit
ecc444db9f
@ -101,16 +101,22 @@ func (d *DatabaseRepo) WithoutByFrom(from string) DBOption {
|
||||
|
||||
func (d *DatabaseRepo) WithTypeList(dbType string) DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
types := strings.Split(dbType, ",")
|
||||
if len(types) == 1 {
|
||||
if !strings.Contains(dbType, ",") {
|
||||
return g.Where("`type` = ?", dbType)
|
||||
}
|
||||
types := strings.Split(dbType, ",")
|
||||
var (
|
||||
rules []string
|
||||
values []interface{}
|
||||
)
|
||||
for _, ty := range types {
|
||||
if len(ty) != 0 {
|
||||
g.Or("`type` = ?", ty)
|
||||
rules = append(rules, "`type` = ?")
|
||||
values = append(values, ty)
|
||||
}
|
||||
}
|
||||
return g
|
||||
fmt.Println(strings.Join(rules, " OR "))
|
||||
return g.Where(strings.Join(rules, " OR "), values...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ var EncryptHostPassword = &gormigrate.Migration{
|
||||
var AddRemoteDB = &gormigrate.Migration{
|
||||
ID: "20230724-add-remote-db",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
if err := tx.AutoMigrate(&model.DatabaseMysql{}); err != nil {
|
||||
if err := tx.AutoMigrate(&model.Database{}, &model.DatabaseMysql{}); err != nil {
|
||||
return err
|
||||
}
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user