Skip to content

Commit

Permalink
t.Type replace t.T
Browse files Browse the repository at this point in the history
\q
\G
\t
;
  • Loading branch information
fizzday committed Jul 24, 2020
1 parent b0213cf commit 0825d77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const (
OBJECT_MAP_SLICE
// OBJECT_STRING 非结构体 表名字符串 ("users")
OBJECT_STRING
// OBJECT_MAP_T map 一条数据 (map[string]t.T)
// OBJECT_MAP_T map 一条数据 (map[string]t.Type)
OBJECT_MAP_T
// OBJECT_MAP_SLICE_T map 多条数据 ([]map[string]t.T)
// OBJECT_MAP_SLICE_T map 多条数据 ([]map[string]t.Type)
OBJECT_MAP_SLICE_T
// OBJECT_NIL 默认没有传入任何绑定对象,一般用于query直接返回
OBJECT_NIL
Expand Down Expand Up @@ -132,7 +132,7 @@ func (o *Binder) BindParse(prefix string) error {
//o.SetBindLimit(1)
//
o.SetBindResult(o.GetBindOrigin())
//TODO 检查map的值类型, 是否是t.T
//TODO 检查map的值类型, 是否是t.Type
if sliceVal.Type().Elem() == reflect.ValueOf(map[string]t.T{}).Type().Elem() {
o.SetBindType(OBJECT_MAP_T)
}
Expand All @@ -153,7 +153,7 @@ func (o *Binder) BindParse(prefix string) error {
o.SetBindResult(reflect.MakeMap(eltType).Interface())
o.SetBindResultSlice(sliceVal)
//o.SetBindResultSlice(reflect.MakeSlice(sliceVal.Type(),0,0))
//TODO 检查map的值类型, 是否是t.T
//TODO 检查map的值类型, 是否是t.Type
if eltType.Elem() == reflect.ValueOf(map[string]t.T{}).Type().Elem() {
o.SetBindType(OBJECT_MAP_SLICE_T)
}
Expand Down
4 changes: 3 additions & 1 deletion examples/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ func initDB() *gorose.Engin {
panic(err.Error())
}

// 这里可以设置日志相关配置
//e.Use(func(eg *gorose.Engin) {
// eg.SetLogger(gorose.NewLogger(&gorose.LogOption{
// FilePath: "log",
// FilePath: "./log",
// EnableSqlLog: true,
// EnableSlowLog: 5,
// EnableErrorLog: true,
Expand All @@ -28,5 +29,6 @@ func main() {
db := initDB().NewOrm()
res,err := db.Table("users").First()
fmt.Println(err)
fmt.Println(db.LastSql())
fmt.Println(res)
}

0 comments on commit 0825d77

Please sign in to comment.