diff --git a/.example/database/gdb/mssql/config.toml b/.example/database/gdb/mssql/config.toml index 80ec002d7..a57e9aa78 100644 --- a/.example/database/gdb/mssql/config.toml +++ b/.example/database/gdb/mssql/config.toml @@ -1,3 +1,3 @@ [database] - linkinfo = "sqlserver://test:test1@122.152.202.91:1433?database=test" \ No newline at end of file + linkinfo = "mssql:user id=test;password=test1;server=122.152.202.91;port=1433;database=test;encrypt=disable" \ No newline at end of file diff --git a/.example/database/gdb/mssql/gdb_all.go b/.example/database/gdb/mssql/gdb_all.go index 8ae5b2b49..da70660b5 100644 --- a/.example/database/gdb/mssql/gdb_all.go +++ b/.example/database/gdb/mssql/gdb_all.go @@ -2,13 +2,22 @@ package main import ( "fmt" + "github.com/gogf/gf/os/gtime" _ "github.com/denisenkom/go-mssqldb" "github.com/gogf/gf/frame/g" ) func main() { - r, err := g.DB().GetAll(`SELECT TOP 10 * FROM KF_PatInfo_Emergency`) - fmt.Println(err) - g.Dump(r.ToList()) + type Table2 struct { + Id string `orm:"id;pr" json:"id"` //ID + Createtime gtime.Time `orm:"createtime" json:"createtime"` //创建时间 + Updatetime gtime.Time `orm:"updatetime" json:"updatetime"` //更新时间 + } + var table2 Table2 + err := g.DB().Table("table2").Where("id=?", 1).Struct(&table2) + if err != nil { + panic(err) + } + fmt.Println(table2.Createtime) } diff --git a/frame/gins/gins.go b/frame/gins/gins.go index a2fc22365..c013aa89e 100644 --- a/frame/gins/gins.go +++ b/frame/gins/gins.go @@ -255,14 +255,8 @@ func parseDBConfigNode(value interface{}) *gdb.ConfigNode { if node.LinkInfo != "" && node.Type == "" { match, _ := gregex.MatchString(`([a-z]+):(.+)`, node.LinkInfo) if len(match) == 3 { - // Special handle for mssql for common usage purpose. - if match[1] == "sqlserver" { - node.Type = "mssql" - node.LinkInfo = node.LinkInfo - } else { - node.Type = match[1] - node.LinkInfo = match[2] - } + node.Type = match[1] + node.LinkInfo = match[2] } } return node diff --git a/go.mod b/go.mod index 4c37a2c14..fd9d70aa1 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.11 require ( github.com/BurntSushi/toml v0.3.1 github.com/clbanning/mxj v1.8.4 + github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e // indirect github.com/fatih/structs v1.1.0 github.com/fsnotify/fsnotify v1.4.7 github.com/gf-third/mysql v1.4.2 diff --git a/os/gtime/gtime_z_unit_time_test.go b/os/gtime/gtime_z_unit_time_test.go index a0de87164..156a24dcb 100644 --- a/os/gtime/gtime_z_unit_time_test.go +++ b/os/gtime/gtime_z_unit_time_test.go @@ -44,6 +44,16 @@ func Test_NewFromStr(t *testing.T) { }) } +func Test_String(t *testing.T) { + gtest.Case(t, func() { + t1 := gtime.NewFromStr("2006-01-02 15:04:05") + gtest.Assert(t1.String(), "2006-01-02 15:04:05") + + t2 := *t1 + gtest.Assert(t2.String(), "2006-01-02 15:04:05") + }) +} + func Test_NewFromStrFormat(t *testing.T) { gtest.Case(t, func() { timeTemp := gtime.NewFromStrFormat("2006-01-02 15:04:05", "Y-m-d H:i:s")