Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加获取 GetSql 方法 #553

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ require (
gopkg.in/yaml.v2 v2.2.8
xorm.io/xorm v1.0.2
)

3 changes: 3 additions & 0 deletions modules/db/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package db

import (
"database/sql"
"strings"
)

// SetColVarType set the column type.
Expand Down Expand Up @@ -35,6 +36,8 @@ func SetColVarType(colVar *[]interface{}, i int, typeName string) {

// SetResultValue set the result value.
func SetResultValue(result *map[string]interface{}, index string, colVar interface{}, typeName string) {
arr := strings.Split(typeName, " ")
typeName = arr[len(arr)-1]
dt := DT(typeName)
switch {
case Contains(dt, BoolTypeList):
Expand Down
6 changes: 6 additions & 0 deletions plugins/admin/modules/table/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,12 @@ func (tb *DefaultTable) sql() *db.SQL {
return db.WithDriverAndConnection(tb.connection, tb.db())
}

// sql is a helper function return db sql.
func (tb *DefaultTable) GetSql() *db.SQL {
return tb.sql()
}


// sqlObjOrNil is a helper function return db sql obj or nil.
func (tb *DefaultTable) sqlObjOrNil() *db.SQL {
if tb.connectionDriver != "" && tb.getDataFromDB() {
Expand Down
3 changes: 3 additions & 0 deletions plugins/admin/modules/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Table interface {
GetOnlyUpdateForm() bool

Copy() Table

GetSql() *db.SQL

}

type BaseTable struct {
Expand Down