Skip to content

Commit

Permalink
修复读取数据库配置失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
azhai committed Aug 14, 2024
1 parent dcbdb0f commit 7203c18
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 102 deletions.
80 changes: 0 additions & 80 deletions cmd/xg/demo.go

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/xm/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion models/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
}

func SetupConns() {
if _, err := cmd.LoadConfigFile(false); err != nil {
if _, err := cmd.LoadConfigFile(true); err != nil {
panic(err)
}
for _, c := range cmd.GetConnConfigs() {
Expand Down
3 changes: 2 additions & 1 deletion templater/preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func init() {
}
func SetupConns() {
if _, err := cmd.LoadConfigFile(false); err != nil {
// 需要重新解析,因为配置可能之前解析过,当时忽略了数据库部分
if _, err := cmd.LoadConfigFile(true); err != nil {
panic(err)
}
for _, c := range cmd.GetConnConfigs() {
Expand Down
4 changes: 2 additions & 2 deletions tests/crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type MenuForTest struct {
*xquery.TimeMixin `json:",inline" xorm:"extends"`
}

func (MenuForTest) TableName() string {
func (*MenuForTest) TableName() string {
return "x_menu_abcd"
}

Expand Down Expand Up @@ -66,7 +66,7 @@ func Test05Delete(t *testing.T) {
}

func Test06Query(t *testing.T) {
table := (MenuForTest{}).TableName()
table := new(MenuForTest).TableName()
sql := fmt.Sprintf("DROP TABLE `%s`", table)
_, err := db.Engine().Query(sql)
assert.NoError(t, err)
Expand Down

0 comments on commit 7203c18

Please sign in to comment.