fix issue in bit type conversion for mssql in gdb

This commit is contained in:
John
2019-07-11 15:41:06 +08:00
parent 2f17d37f7b
commit 10e042454c
3 changed files with 33 additions and 12 deletions

View File

@ -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:

View File

@ -0,0 +1,8 @@
[database]
type = "mssql"
host = "116.255.140.92"
port = "1451"
user = "sa"
pass = "eno@123"
name = "frpc"

View 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())
}