修复代码BUG + 循环引用

This commit is contained in:
2024-08-23 17:54:48 +08:00
parent f359598109
commit c6b8d29b61
9 changed files with 154 additions and 115 deletions

View File

@ -78,7 +78,7 @@ func (e *execute) List(ctx context.Context, inputParam *define.Api2SqlParam) (an
var (
err error
tx *gorm.DB
optionList []database.SetOption
optionList []define.SetOption
)
if tx, err = e.getTx(ctx, inputParam); nil != err {
return nil, err
@ -227,7 +227,7 @@ func (e *execute) validateColumn(inputParam *define.Api2SqlParam) error {
// 验证字段是否都正确
tableColumnTable := make(map[string]bool)
for _, itemColumn := range inputParam.TableColumnConfig {
tableColumnTable[itemColumn.ColumnName] = true
tableColumnTable[itemColumn.Column] = true
}
for _, columnConfig := range inputParam.ColumnList {
if !tableColumnTable[columnConfig.Column] {
@ -261,8 +261,8 @@ func (e *execute) getTx(ctx context.Context, inputParam *define.Api2SqlParam) (*
// Author : go_developer@163.com<白茶清欢>
//
// Date : 12:31 2024/8/23
func (e *execute) getOptionList(ctx context.Context, inputParam *define.Api2SqlParam) ([]database.SetOption, error) {
optionList := []database.SetOption{
func (e *execute) getOptionList(ctx context.Context, inputParam *define.Api2SqlParam) ([]define.SetOption, error) {
optionList := []define.SetOption{
database.WithTable(inputParam.Table),
}
// 设置 limit offset

31
api2sql/execute_test.go Normal file
View File

@ -0,0 +1,31 @@
// Package api2sql ...
//
// Description : api2sql ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-08-23 17:36
package api2sql
import (
"git.zhangdeman.cn/zhangdeman/database"
"git.zhangdeman.cn/zhangdeman/database/define"
"testing"
)
func Test_execute_Run(t *testing.T) {
clientManager := database.NewWrapperClient()
if err := clientManager.AddWithConfig("TEST_DATABASE", nil, &define.Database{
Master: &define.Driver{
DBType: "sqlite3",
Host: "/tmp/gateway.db",
},
Slave: &define.Driver{
DBType: "sqlite3",
Host: "/tmp/gateway.db",
},
}, []string{}); nil != err {
panic(err.Error())
}
Exec.SetDatabaseClientManager(clientManager)
}