Merge main & resolve conflict
This commit is contained in:
4
client/cache/README.md
vendored
4
client/cache/README.md
vendored
@@ -4,7 +4,7 @@ cache is a Go cache manager. It can use many cache adapters. The repo is inspire
|
||||
|
||||
## How to install?
|
||||
|
||||
go get github.com/beego/beego/v2/cache
|
||||
go get github.com/beego/beego/v2/client/cache
|
||||
|
||||
## What adapters are supported?
|
||||
|
||||
@@ -15,7 +15,7 @@ As of now this cache support memory, Memcache and Redis.
|
||||
First you must import it
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/cache"
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
)
|
||||
|
||||
Then init a Cache (example with memory adapter)
|
||||
|
||||
2
client/cache/cache.go
vendored
2
client/cache/cache.go
vendored
@@ -16,7 +16,7 @@
|
||||
// Usage:
|
||||
//
|
||||
// import(
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
||||
|
||||
2
client/cache/calc_utils.go
vendored
2
client/cache/calc_utils.go
vendored
@@ -80,4 +80,4 @@ func decr(originVal interface{}) (interface{}, error) {
|
||||
default:
|
||||
return nil, fmt.Errorf("item val is not (u)int (u)int32 (u)int64")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
client/cache/calc_utils_test.go
vendored
6
client/cache/calc_utils_test.go
vendored
@@ -19,7 +19,7 @@ func TestIncr(t *testing.T) {
|
||||
t.Errorf("incr failed, expect %v, but %v actually", updateVal, val)
|
||||
return
|
||||
}
|
||||
_, err = incr(int(1 << (strconv.IntSize - 1) - 1))
|
||||
_, err = incr(int(1<<(strconv.IntSize-1) - 1))
|
||||
if err == nil {
|
||||
t.Error("incr failed")
|
||||
return
|
||||
@@ -73,7 +73,7 @@ func TestIncr(t *testing.T) {
|
||||
t.Errorf("incr failed, expect %v, but %v actually", updateVal, val)
|
||||
return
|
||||
}
|
||||
_, err = incr(uint(1 << (strconv.IntSize) - 1))
|
||||
_, err = incr(uint(1<<(strconv.IntSize) - 1))
|
||||
if err == nil {
|
||||
t.Error("incr failed")
|
||||
return
|
||||
@@ -238,4 +238,4 @@ func TestDecr(t *testing.T) {
|
||||
t.Error("decr failed")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
client/cache/memcache/memcache.go
vendored
4
client/cache/memcache/memcache.go
vendored
@@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/memcache"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/memcache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||
|
||||
4
client/cache/redis/redis.go
vendored
4
client/cache/redis/redis.go
vendored
@@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/redis"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/redis"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||
|
||||
@@ -8,7 +8,7 @@ httplib is an libs help you to curl remote url.
|
||||
|
||||
you can use Get to crawl data.
|
||||
|
||||
import "github.com/beego/beego/v2/httplib"
|
||||
import "github.com/beego/beego/v2/client/httplib"
|
||||
|
||||
str, err := httplib.Get("http://beego.me/").String()
|
||||
if err != nil {
|
||||
@@ -95,4 +95,4 @@ httplib support mutil file upload, use `req.PostFile()`
|
||||
|
||||
See godoc for further documentation and examples.
|
||||
|
||||
* [godoc.org/github.com/beego/beego/v2/httplib](https://godoc.org/github.com/beego/beego/v2/httplib)
|
||||
* [godoc.org/github.com/beego/beego/v2/client/httplib](https://godoc.org/github.com/beego/beego/v2/client/httplib)
|
||||
|
||||
@@ -51,7 +51,6 @@ Sometimes you got JSON document and you want to make it as request body. So you
|
||||
If you do this, you got this code. Instead, you should call Header to set Content-type and call Body to set body data.
|
||||
`)
|
||||
|
||||
|
||||
// start with 5 --------------------------------------------------------------------------
|
||||
|
||||
var CreateFormFileFailed = berror.DefineCode(5001001, moduleName, "CreateFormFileFailed", `
|
||||
@@ -125,7 +124,3 @@ Make sure that:
|
||||
1. You pass valid structure pointer to the function;
|
||||
2. The body is valid YAML document
|
||||
`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
func TestNewHttpResponseWithJsonBody(t *testing.T) {
|
||||
// string
|
||||
resp := NewHttpResponseWithJsonBody("{}")
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// Package httplib is used as http.Client
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/httplib"
|
||||
// import "github.com/beego/beego/v2/client/httplib"
|
||||
//
|
||||
// b := httplib.Post("http://beego.me/")
|
||||
// b.Param("username","astaxie")
|
||||
|
||||
@@ -309,7 +309,6 @@ func TestFilterChainOrder(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
req.AddFilters(func(next Filter) Filter {
|
||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||
return NewHttpResponseWithJsonBody("second"), nil
|
||||
@@ -396,7 +395,7 @@ func TestBeegoHTTPRequest_Param(t *testing.T) {
|
||||
req.Param(key, value)
|
||||
assert.Equal(t, value, req.params[key][0])
|
||||
|
||||
value1 := "test-param-value-1"
|
||||
value1 := "test-param-value-1"
|
||||
req.Param(key, value1)
|
||||
assert.Equal(t, value1, req.params[key][1])
|
||||
}
|
||||
@@ -419,10 +418,10 @@ func TestBeegoHTTPRequest_Body(t *testing.T) {
|
||||
req.Body(13)
|
||||
}
|
||||
|
||||
|
||||
type user struct {
|
||||
Name string `xml:"name"`
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequest_XMLBody(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
body := &user{
|
||||
@@ -432,4 +431,4 @@ func TestBeegoHTTPRequest_XMLBody(t *testing.T) {
|
||||
assert.True(t, req.req.ContentLength > 0)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, req.req.GetBody)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func StartMock() Stub {
|
||||
return mockFilter
|
||||
}
|
||||
|
||||
func CtxWithMock(ctx context.Context, mock... *Mock) context.Context {
|
||||
func CtxWithMock(ctx context.Context, mock ...*Mock) context.Context {
|
||||
return context.WithValue(ctx, mockCtxKey, mock)
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@ func NewMock(con RequestCondition, resp *http.Response, err error) *Mock {
|
||||
return &Mock{
|
||||
cond: con,
|
||||
resp: resp,
|
||||
err: err,
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,6 @@ func (sc *SimpleCondition) matchBodyFields(ctx context.Context, req *httplib.Bee
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
m := make(map[string]interface{})
|
||||
|
||||
err = json.Unmarshal(bytes, &m)
|
||||
|
||||
@@ -72,6 +72,6 @@ func OriginnalCodeUsingHttplibPassCtx(ctx context.Context) (*http.Response, erro
|
||||
return httplib.Get("http://localhost:7777/abc").DoRequestWithCtx(ctx)
|
||||
}
|
||||
|
||||
func OriginalCodeUsingHttplib() (*http.Response, error){
|
||||
func OriginalCodeUsingHttplib() (*http.Response, error) {
|
||||
return httplib.Get("http://localhost:7777/abc").DoRequest()
|
||||
}
|
||||
|
||||
@@ -78,4 +78,4 @@ func AddDefaultFilter(fc FilterChain) {
|
||||
defaultSetting.FilterChains = make([]FilterChain, 0, 4)
|
||||
}
|
||||
defaultSetting.FilterChains = append(defaultSetting.FilterChains, fc)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ more features please read the docs
|
||||
|
||||
**Install:**
|
||||
|
||||
go get github.com/beego/beego/v2/orm
|
||||
go get github.com/beego/beego/v2/client/orm
|
||||
|
||||
## Changelog
|
||||
|
||||
@@ -45,7 +45,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
_ "github.com/go-sql-driver/mysql" // import your used driver
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package clauses
|
||||
|
||||
const (
|
||||
ExprSep = "__"
|
||||
ExprDot = "."
|
||||
ExprSep = "__"
|
||||
ExprDot = "."
|
||||
)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package order_clause
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
)
|
||||
|
||||
type Sort int8
|
||||
|
||||
@@ -16,10 +16,11 @@ package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
)
|
||||
|
||||
// table info struct.
|
||||
|
||||
@@ -23,14 +23,14 @@ import (
|
||||
type Mock struct {
|
||||
cond Condition
|
||||
resp []interface{}
|
||||
cb func(inv *orm.Invocation)
|
||||
cb func(inv *orm.Invocation)
|
||||
}
|
||||
|
||||
func NewMock(cond Condition, resp []interface{}, cb func(inv *orm.Invocation)) *Mock {
|
||||
return &Mock{
|
||||
cond: cond,
|
||||
resp: resp,
|
||||
cb: cb,
|
||||
cb: cb,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@ import (
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
const mockErrorMsg = "mock error"
|
||||
|
||||
func init() {
|
||||
orm.RegisterModel(&User{})
|
||||
}
|
||||
@@ -239,7 +241,7 @@ func TestTransactionRollback(t *testing.T) {
|
||||
assert.Equal(t, mock, err)
|
||||
}
|
||||
|
||||
func TestTransactionCommit(t *testing.T) {
|
||||
func TestTransactionCommit(t *testing.T) {
|
||||
s := StartMock()
|
||||
defer s.Clear()
|
||||
mock := errors.New(mockErrorMsg)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
// DoNothingQueryM2Mer do nothing
|
||||
// use it to build mock orm.QueryM2Mer
|
||||
type DoNothingQueryM2Mer struct {
|
||||
|
||||
}
|
||||
|
||||
func (d *DoNothingQueryM2Mer) AddWithCtx(ctx context.Context, i ...interface{}) (int64, error) {
|
||||
@@ -68,13 +67,13 @@ func (d *DoNothingQueryM2Mer) Count() (int64, error) {
|
||||
|
||||
type QueryM2MerCondition struct {
|
||||
tableName string
|
||||
name string
|
||||
name string
|
||||
}
|
||||
|
||||
func NewQueryM2MerCondition(tableName string, name string) *QueryM2MerCondition {
|
||||
return &QueryM2MerCondition{
|
||||
tableName: tableName,
|
||||
name: name,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,5 +87,3 @@ func (q *QueryM2MerCondition) Match(ctx context.Context, inv *orm.Invocation) bo
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,4 +60,4 @@ func TestNewQueryM2MerCondition(t *testing.T) {
|
||||
assert.True(t, cond.Match(context.Background(), &orm.Invocation{
|
||||
Args: []interface{}{0, "A"},
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,4 @@ func (d *DoNothingRawSetter) RowsToStruct(ptrStruct interface{}, keyCol, valueCo
|
||||
|
||||
func (d *DoNothingRawSetter) Prepare() (orm.RawPreparer, error) {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ func (mc *_modelCache) register(prefixOrSuffixStr string, prefixOrSuffix bool, m
|
||||
}
|
||||
|
||||
if _, ok := mc.get(table); ok {
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
mi := newModelInfo(val)
|
||||
|
||||
@@ -58,11 +58,12 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"os"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/hints"
|
||||
"github.com/beego/beego/v2/core/utils"
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@ package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
)
|
||||
|
||||
// ExprSep define the expression separation
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
@@ -32,6 +31,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/hints"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -216,19 +216,25 @@ type DriverGetter interface {
|
||||
Driver() Driver
|
||||
}
|
||||
|
||||
|
||||
type ormer interface {
|
||||
DQL
|
||||
DML
|
||||
DriverGetter
|
||||
}
|
||||
|
||||
type Ormer interface {
|
||||
//QueryExecutor wrapping for ormer
|
||||
type QueryExecutor interface {
|
||||
ormer
|
||||
}
|
||||
|
||||
type Ormer interface {
|
||||
QueryExecutor
|
||||
TxBeginner
|
||||
}
|
||||
|
||||
type TxOrmer interface {
|
||||
ormer
|
||||
QueryExecutor
|
||||
TxCommitter
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user