remove debug info
This commit is contained in:
parent
894e97e195
commit
affc64cde3
37
session.go
37
session.go
|
@ -95,8 +95,8 @@ func (session *Session) Desc(colNames ...string) *Session {
|
||||||
if session.Statement.OrderStr != "" {
|
if session.Statement.OrderStr != "" {
|
||||||
session.Statement.OrderStr += ", "
|
session.Statement.OrderStr += ", "
|
||||||
}
|
}
|
||||||
sql := strings.Join(colNames, " desc, ")
|
sql := strings.Join(colNames, session.Engine.Quote(" DESC, "))
|
||||||
session.Statement.OrderStr += sql + " desc"
|
session.Statement.OrderStr += session.Engine.Quote(sql) + " DESC"
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ func (session *Session) Asc(colNames ...string) *Session {
|
||||||
if session.Statement.OrderStr != "" {
|
if session.Statement.OrderStr != "" {
|
||||||
session.Statement.OrderStr += ", "
|
session.Statement.OrderStr += ", "
|
||||||
}
|
}
|
||||||
sql := strings.Join(colNames, " asc, ")
|
sql := strings.Join(colNames, session.Engine.Quote(" ASC, "))
|
||||||
session.Statement.OrderStr += sql + " asc"
|
session.Statement.OrderStr += session.Engine.Quote(sql) + " ASC"
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ func (session *Session) cacheGet(bean interface{}, sql string, args ...interface
|
||||||
cacher := session.Statement.RefTable.Cacher
|
cacher := session.Statement.RefTable.Cacher
|
||||||
ids, err := GetCacheSql(cacher, newsql)
|
ids, err := GetCacheSql(cacher, newsql)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
//fmt.Println(err)
|
||||||
resultsSlice, err := session.query(newsql, args...)
|
resultsSlice, err := session.query(newsql, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -416,10 +416,11 @@ func (session *Session) cacheGet(bean interface{}, sql string, args ...interface
|
||||||
}
|
}
|
||||||
err = PutCacheSql(cacher, newsql, ids)
|
err = PutCacheSql(cacher, newsql, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
//fmt.Println(err)
|
||||||
|
return false, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
//fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
||||||
}
|
}
|
||||||
|
|
||||||
//fmt.Println("xxxxxxx", ids)
|
//fmt.Println("xxxxxxx", ids)
|
||||||
|
@ -430,7 +431,7 @@ func (session *Session) cacheGet(bean interface{}, sql string, args ...interface
|
||||||
tableName := session.Statement.TableName()
|
tableName := session.Statement.TableName()
|
||||||
cacheBean := GetCacheId(cacher, tableName, id)
|
cacheBean := GetCacheId(cacher, tableName, id)
|
||||||
if cacheBean == nil {
|
if cacheBean == nil {
|
||||||
fmt.Printf("----Object Id %v no cached.\n", id)
|
//fmt.Printf("----Object Id %v no cached.\n", id)
|
||||||
newSession := session.Engine.NewSession()
|
newSession := session.Engine.NewSession()
|
||||||
defer newSession.Close()
|
defer newSession.Close()
|
||||||
cacheBean = reflect.New(structValue.Type()).Interface()
|
cacheBean = reflect.New(structValue.Type()).Interface()
|
||||||
|
@ -441,7 +442,7 @@ func (session *Session) cacheGet(bean interface{}, sql string, args ...interface
|
||||||
//fmt.Println(bean)
|
//fmt.Println(bean)
|
||||||
PutCacheId(cacher, tableName, id, cacheBean)
|
PutCacheId(cacher, tableName, id, cacheBean)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached Object: %v\n", cacheBean)
|
//fmt.Printf("-----Cached Object: %v\n", cacheBean)
|
||||||
has = true
|
has = true
|
||||||
}
|
}
|
||||||
//fmt.Println(cacheBean, reflect.ValueOf(cacheBean))
|
//fmt.Println(cacheBean, reflect.ValueOf(cacheBean))
|
||||||
|
@ -471,7 +472,7 @@ func (session *Session) cacheFind(t reflect.Type, sql string, rowsSlicePtr inter
|
||||||
cacher := table.Cacher
|
cacher := table.Cacher
|
||||||
ids, err := GetCacheSql(cacher, newsql)
|
ids, err := GetCacheSql(cacher, newsql)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
//fmt.Println(err)
|
||||||
resultsSlice, err := session.query(newsql, args...)
|
resultsSlice, err := session.query(newsql, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -498,10 +499,11 @@ func (session *Session) cacheFind(t reflect.Type, sql string, rowsSlicePtr inter
|
||||||
}
|
}
|
||||||
err = PutCacheSql(cacher, newsql, ids)
|
err = PutCacheSql(cacher, newsql, ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
//fmt.Println(err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
//fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
||||||
}
|
}
|
||||||
|
|
||||||
sliceValue := reflect.Indirect(reflect.ValueOf(rowsSlicePtr))
|
sliceValue := reflect.Indirect(reflect.ValueOf(rowsSlicePtr))
|
||||||
|
@ -513,11 +515,11 @@ func (session *Session) cacheFind(t reflect.Type, sql string, rowsSlicePtr inter
|
||||||
for idx, id := range ids {
|
for idx, id := range ids {
|
||||||
bean := GetCacheId(cacher, tableName, id)
|
bean := GetCacheId(cacher, tableName, id)
|
||||||
if bean == nil {
|
if bean == nil {
|
||||||
fmt.Printf("----Object Id %v no cached.\n", id)
|
//fmt.Printf("----Object Id %v no cached.\n", id)
|
||||||
idxes = append(idxes, idx)
|
idxes = append(idxes, idx)
|
||||||
ides = append(ides, id)
|
ides = append(ides, id)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached Object: %v\n", bean)
|
//fmt.Printf("-----Cached Object: %v\n", bean)
|
||||||
temps[idx] = bean
|
temps[idx] = bean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -785,7 +787,7 @@ func (session *Session) query(sql string, paramStr ...interface{}) (resultsSlice
|
||||||
|
|
||||||
//if row is null then ignore
|
//if row is null then ignore
|
||||||
if rawValue.Interface() == nil {
|
if rawValue.Interface() == nil {
|
||||||
fmt.Println("ignore ...", key, rawValue)
|
//fmt.Println("ignore ...", key, rawValue)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
aa := reflect.TypeOf(rawValue.Interface())
|
aa := reflect.TypeOf(rawValue.Interface())
|
||||||
|
@ -1351,7 +1353,7 @@ func (session *Session) cacheUpdate(sql string, args ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
//fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
||||||
DelCacheSql(cacher, newsql)
|
DelCacheSql(cacher, newsql)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1408,6 +1410,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
||||||
if t.Kind() == reflect.Struct {
|
if t.Kind() == reflect.Struct {
|
||||||
table = session.Engine.AutoMap(bean)
|
table = session.Engine.AutoMap(bean)
|
||||||
session.Statement.RefTable = table
|
session.Statement.RefTable = table
|
||||||
|
|
||||||
colNames, args = BuildConditions(session.Engine, table, bean)
|
colNames, args = BuildConditions(session.Engine, table, bean)
|
||||||
if session.Statement.UseAutoTime && table.Updated != "" {
|
if session.Statement.UseAutoTime && table.Updated != "" {
|
||||||
colNames = append(colNames, session.Engine.Quote(table.Updated)+" = ?")
|
colNames = append(colNames, session.Engine.Quote(table.Updated)+" = ?")
|
||||||
|
@ -1514,7 +1517,7 @@ func (session *Session) cacheDelete(sql string, args ...interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
//fmt.Printf("-----Cached SQL: %v.\n", newsql)
|
||||||
DelCacheSql(cacher, newsql)
|
DelCacheSql(cacher, newsql)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue