Skip to content

Commit

Permalink
调整:手动执行SQL时,支持自动替换{database}、{table}标签
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Feb 22, 2024
1 parent 8f11ee6 commit 36bdf94
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tableSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ type whereQuery struct {
func (receiver *TableSet[Table]) Init(dbContext *internalContext, param map[string]string) {
receiver.dbContext = dbContext
receiver.GetPrimaryName()
db := receiver.getOrCreateSession().ormClient
// 表名
if name, exists := param["name"]; exists {
receiver.SetTableName(name)
} else {
}

db := receiver.getOrCreateSession().ormClient
if receiver.tableName == "" {
receiver.SetTableName(db.Statement.Table)
}

receiver.dbName = db.Migrator().CurrentDatabase()
receiver.nameReplacer = strings.NewReplacer("{database}", receiver.dbName, "{table}", receiver.tableName)
// 自动创建表
Expand Down

0 comments on commit 36bdf94

Please sign in to comment.