mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
fix issue in bit type conversion for mssql in gdb
This commit is contained in:
@ -8,20 +8,19 @@ package gdb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/g/text/gregex"
|
||||
"github.com/gogf/gf/g/util/gconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
// 同步数据库表结构到内存中
|
||||
func (bs *dbBase) syncTableStructure() {
|
||||
bs.tables = make(map[string]map[string]string)
|
||||
for _, table := range bs.db.getTables() {
|
||||
bs.tables[table], _ = bs.db.getTableFields(table)
|
||||
}
|
||||
}
|
||||
*/
|
||||
//// 同步数据库表结构到内存中
|
||||
//func (bs *dbBase) syncTableStructure() {
|
||||
// bs.tables = make(map[string]map[string]string)
|
||||
// for _, table := range bs.db.getTables() {
|
||||
// bs.tables[table], _ = bs.db.getTableFields(table)
|
||||
// }
|
||||
//}
|
||||
|
||||
// 字段类型转换,将数据库字段类型转换为golang变量类型
|
||||
func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interface{} {
|
||||
@ -31,7 +30,7 @@ func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interfa
|
||||
case "binary", "varbinary", "blob", "tinyblob", "mediumblob", "longblob":
|
||||
return gconv.Bytes(fieldValue)
|
||||
|
||||
case "bit", "int", "tinyint", "small_int", "medium_int":
|
||||
case "int", "tinyint", "small_int", "medium_int":
|
||||
return gconv.Int(fieldValue)
|
||||
|
||||
case "big_int":
|
||||
@ -40,7 +39,7 @@ func (bs *dbBase) convertValue(fieldValue interface{}, fieldType string) interfa
|
||||
case "float", "double", "decimal":
|
||||
return gconv.Float64(fieldValue)
|
||||
|
||||
case "bool":
|
||||
case "bit", "bool":
|
||||
return gconv.Bool(fieldValue)
|
||||
|
||||
default:
|
||||
|
||||
8
geg/database/gdb/mssql/config.toml
Normal file
8
geg/database/gdb/mssql/config.toml
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
[database]
|
||||
type = "mssql"
|
||||
host = "116.255.140.92"
|
||||
port = "1451"
|
||||
user = "sa"
|
||||
pass = "eno@123"
|
||||
name = "frpc"
|
||||
14
geg/database/gdb/mssql/gdb_all.go
Normal file
14
geg/database/gdb/mssql/gdb_all.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
//_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/gogf/gf/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r, err := g.DB().GetAll(`SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 * FROM KF_PatInfo_Emergency WHERE Report_BZ = 1 AND Examine_BZ = 0 ) as TMP1_ ) as TMP2_`)
|
||||
fmt.Println(err)
|
||||
g.Dump(r.ToList())
|
||||
}
|
||||
Reference in New Issue
Block a user