start v2
This commit is contained in:
parent
6ef0a7798f
commit
41154ea9ae
|
@ -12,7 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLRUCache(t *testing.T) {
|
func TestLRUCache(t *testing.T) {
|
||||||
|
@ -40,7 +40,7 @@ func TestLRUCache(t *testing.T) {
|
||||||
obj2 := cacher.GetBean(tableName, sid)
|
obj2 := cacher.GetBean(tableName, sid)
|
||||||
assert.Nil(t, obj2)
|
assert.Nil(t, obj2)
|
||||||
|
|
||||||
var obj = new(CacheObject1)
|
obj := new(CacheObject1)
|
||||||
cacher.PutBean(tableName, sid, obj)
|
cacher.PutBean(tableName, sid, obj)
|
||||||
obj3 := cacher.GetBean(tableName, sid)
|
obj3 := cacher.GetBean(tableName, sid)
|
||||||
assert.EqualValues(t, obj, obj3)
|
assert.EqualValues(t, obj, obj3)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// String2Time converts a string to time with original location
|
// String2Time converts a string to time with original location
|
||||||
|
|
20
core/db.go
20
core/db.go
|
@ -13,15 +13,13 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// DefaultCacheSize sets the default cache size
|
||||||
// DefaultCacheSize sets the default cache size
|
var DefaultCacheSize = 200
|
||||||
DefaultCacheSize = 200
|
|
||||||
)
|
|
||||||
|
|
||||||
// MapToSlice map query and struct as sql and args
|
// MapToSlice map query and struct as sql and args
|
||||||
func MapToSlice(query string, mp interface{}) (string, []interface{}, error) {
|
func MapToSlice(query string, mp interface{}) (string, []interface{}, error) {
|
||||||
|
@ -79,9 +77,7 @@ type cacheStruct struct {
|
||||||
idx int
|
idx int
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var _ QueryExecuter = &DB{}
|
||||||
_ QueryExecuter = &DB{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// DB is a wrap of sql.DB with extra contents
|
// DB is a wrap of sql.DB with extra contents
|
||||||
type DB struct {
|
type DB struct {
|
||||||
|
@ -234,9 +230,7 @@ func (db *DB) QueryRowStruct(query string, st interface{}) *Row {
|
||||||
return db.QueryRowStructContext(context.Background(), query, st)
|
return db.QueryRowStructContext(context.Background(), query, st)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var re = regexp.MustCompile(`[?](\w+)`)
|
||||||
re = regexp.MustCompile(`[?](\w+)`)
|
|
||||||
)
|
|
||||||
|
|
||||||
// ExecMapContext exec map with context.ContextHook
|
// ExecMapContext exec map with context.ContextHook
|
||||||
// insert into (name) values (?)
|
// insert into (name) values (?)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
@ -625,7 +625,8 @@ func TestExecStruct(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user := User{Name: "xlw",
|
user := User{
|
||||||
|
Name: "xlw",
|
||||||
Title: "tester",
|
Title: "tester",
|
||||||
Age: 1.2,
|
Age: 1.2,
|
||||||
Alias: "lunny",
|
Alias: "lunny",
|
||||||
|
@ -670,7 +671,8 @@ func BenchmarkExecStruct(b *testing.B) {
|
||||||
|
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
|
|
||||||
user := User{Name: "xlw",
|
user := User{
|
||||||
|
Name: "xlw",
|
||||||
Title: "tester",
|
Title: "tester",
|
||||||
Age: 1.2,
|
Age: 1.2,
|
||||||
Alias: "lunny",
|
Alias: "lunny",
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stmt reprents a stmt objects
|
// Stmt reprents a stmt objects
|
||||||
|
|
|
@ -8,12 +8,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var _ QueryExecuter = &Tx{}
|
||||||
_ QueryExecuter = &Tx{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Tx represents a transaction
|
// Tx represents a transaction
|
||||||
type Tx struct {
|
type Tx struct {
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// URI represents an uri to visit database
|
// URI represents an uri to visit database
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ScanContext represents a context when Scan
|
// ScanContext represents a context when Scan
|
||||||
|
@ -31,9 +31,7 @@ type Driver interface {
|
||||||
Scan(*ScanContext, *core.Rows, []*sql.ColumnType, ...interface{}) error
|
Scan(*ScanContext, *core.Rows, []*sql.ColumnType, ...interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var drivers = map[string]Driver{}
|
||||||
drivers = map[string]Driver{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// RegisterDriver register a driver
|
// RegisterDriver register a driver
|
||||||
func RegisterDriver(driverName string, driver Driver) {
|
func RegisterDriver(driverName string, driver Driver) {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// from http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
|
// from http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TableNameWithSchema will add schema prefix on table name if possible
|
// TableNameWithSchema will add schema prefix on table name if possible
|
||||||
|
|
|
@ -7,7 +7,7 @@ package dialects
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FormatColumnTime format column time
|
// FormatColumnTime format column time
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type dialect struct {
|
type dialect struct {
|
||||||
|
|
18
engine.go
18
engine.go
|
@ -17,15 +17,15 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
"xorm.io/xorm/tags"
|
"xorm.io/xorm/v2/tags"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Engine is the major struct of xorm, it means a database manager.
|
// Engine is the major struct of xorm, it means a database manager.
|
||||||
|
|
|
@ -8,11 +8,11 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EngineGroup defines an engine group
|
// EngineGroup defines an engine group
|
||||||
|
|
43
go.mod
43
go.mod
|
@ -1,13 +1,12 @@
|
||||||
module xorm.io/xorm
|
module xorm.io/xorm/v2
|
||||||
|
|
||||||
go 1.16
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitee.com/travelliu/dm v1.8.11192
|
gitee.com/travelliu/dm v1.8.11192
|
||||||
github.com/denisenkom/go-mssqldb v0.12.3
|
github.com/denisenkom/go-mssqldb v0.12.3
|
||||||
github.com/go-sql-driver/mysql v1.7.0
|
github.com/go-sql-driver/mysql v1.7.0
|
||||||
github.com/goccy/go-json v0.8.1
|
github.com/goccy/go-json v0.8.1
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
|
||||||
github.com/jackc/pgx/v4 v4.18.0
|
github.com/jackc/pgx/v4 v4.18.0
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/lib/pq v1.10.7
|
github.com/lib/pq v1.10.7
|
||||||
|
@ -18,4 +17,42 @@ require (
|
||||||
github.com/ziutek/mymysql v1.5.4
|
github.com/ziutek/mymysql v1.5.4
|
||||||
modernc.org/sqlite v1.20.4
|
modernc.org/sqlite v1.20.4
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978
|
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978
|
||||||
|
xorm.io/xorm v1.3.4
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
|
||||||
|
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
||||||
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
|
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||||
|
github.com/jackc/pgconn v1.14.0 // indirect
|
||||||
|
github.com/jackc/pgio v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||||
|
github.com/jackc/pgtype v1.14.0 // indirect
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
|
||||||
|
golang.org/x/crypto v0.6.0 // indirect
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||||
|
golang.org/x/sys v0.5.0 // indirect
|
||||||
|
golang.org/x/text v0.7.0 // indirect
|
||||||
|
golang.org/x/tools v0.1.12 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
lukechampine.com/uint128 v1.2.0 // indirect
|
||||||
|
modernc.org/cc/v3 v3.40.0 // indirect
|
||||||
|
modernc.org/ccgo/v3 v3.16.13 // indirect
|
||||||
|
modernc.org/libc v1.22.2 // indirect
|
||||||
|
modernc.org/mathutil v1.5.0 // indirect
|
||||||
|
modernc.org/memory v1.4.0 // indirect
|
||||||
|
modernc.org/opt v0.1.3 // indirect
|
||||||
|
modernc.org/strutil v1.1.3 // indirect
|
||||||
|
modernc.org/token v1.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -55,7 +55,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
|
||||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||||
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
|
|
||||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||||
|
@ -76,7 +75,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W
|
||||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
|
|
||||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||||
|
@ -343,3 +341,5 @@ modernc.org/z v1.7.0 h1:xkDw/KepgEjeizO2sNco+hqYkU12taxQFqPEmgm1GWE=
|
||||||
modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
|
modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 h1:bvLlAPW1ZMTWA32LuZMBEGHAUOcATZjzHcotf3SWweM=
|
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 h1:bvLlAPW1ZMTWA32LuZMBEGHAUOcATZjzHcotf3SWweM=
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
||||||
|
xorm.io/xorm v1.3.4 h1:vWFKzR3DhGUDl5b4srhUjhDwjxkZAc4C7BFszpu0swI=
|
||||||
|
xorm.io/xorm v1.3.4/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=
|
||||||
|
|
12
interface.go
12
interface.go
|
@ -10,12 +10,12 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Interface defines the interface which Engine, EngineGroup and Session will implementate.
|
// Interface defines the interface which Engine, EngineGroup and Session will implementate.
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConvertIDSQL converts SQL with id
|
// ConvertIDSQL converts SQL with id
|
||||||
|
|
|
@ -7,7 +7,7 @@ package statements
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type columnMap []string
|
type columnMap []string
|
||||||
|
|
|
@ -6,7 +6,7 @@ package statements
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QuoteReplacer struct {
|
type QuoteReplacer struct {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (statement *Statement) writeDeleteOrder(w *builder.BytesWriter) error {
|
func (statement *Statement) writeDeleteOrder(w *builder.BytesWriter) error {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrUnsupportedExprType represents an error with unsupported express type
|
// ErrUnsupportedExprType represents an error with unsupported express type
|
||||||
|
@ -59,7 +59,7 @@ func (expr *Expr) WriteArgs(w *builder.BytesWriter) error {
|
||||||
type exprParams []Expr
|
type exprParams []Expr
|
||||||
|
|
||||||
func (exprs exprParams) ColNames() []string {
|
func (exprs exprParams) ColNames() []string {
|
||||||
var cols = make([]string, 0, len(exprs))
|
cols := make([]string, 0, len(exprs))
|
||||||
for _, expr := range exprs {
|
for _, expr := range exprs {
|
||||||
cols = append(cols, expr.ColName)
|
cols = append(cols, expr.ColName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (statement *Statement) writeInsertOutput(buf *strings.Builder, table *schemas.Table) error {
|
func (statement *Statement) writeInsertOutput(buf *strings.Builder, table *schemas.Table) error {
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (statement *Statement) writePagination(bw *builder.BytesWriter) error {
|
func (statement *Statement) writePagination(bw *builder.BytesWriter) error {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -91,7 +91,7 @@ func (statement *Statement) ProcessIDParam() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, col := range statement.RefTable.PKColumns() {
|
for i, col := range statement.RefTable.PKColumns() {
|
||||||
var colName = statement.colName(col, statement.TableName())
|
colName := statement.colName(col, statement.TableName())
|
||||||
statement.cond = statement.cond.And(builder.Eq{colName: statement.idParam[i]})
|
statement.cond = statement.cond.And(builder.Eq{colName: statement.idParam[i]})
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GenQuerySQL generate query SQL
|
// GenQuerySQL generate query SQL
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Select replace select
|
// Select replace select
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/v2/internal/json"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
"xorm.io/xorm/tags"
|
"xorm.io/xorm/v2/tags"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -6,7 +6,7 @@ package statements
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteArg writes an arg
|
// WriteArg writes an arg
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
"xorm.io/xorm/tags"
|
"xorm.io/xorm/v2/tags"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TableName return current tableName
|
// TableName return current tableName
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/v2/internal/json"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion, includeUpdated, includeNil,
|
func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion, includeUpdated, includeNil,
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/v2/internal/json"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -7,7 +7,7 @@ package log
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LogContext represents a log context
|
// LogContext represents a log context
|
||||||
|
@ -35,9 +35,7 @@ type ContextLogger interface {
|
||||||
IsShowSQL() bool
|
IsShowSQL() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var _ ContextLogger = &LoggerAdapter{}
|
||||||
_ ContextLogger = &LoggerAdapter{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// enumerate all the context keys
|
// enumerate all the context keys
|
||||||
var (
|
var (
|
||||||
|
|
2
rows.go
2
rows.go
|
@ -10,7 +10,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Rows rows wrapper a rows to
|
// Rows rows wrapper a rows to
|
||||||
|
|
8
scan.go
8
scan.go
|
@ -11,10 +11,10 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// genScanResultsByBeanNullabale generates scan result
|
// genScanResultsByBeanNullabale generates scan result
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PK represents primary key values
|
// PK represents primary key values
|
||||||
|
|
15
session.go
15
session.go
|
@ -16,13 +16,14 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"xorm.io/xorm/contexts"
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/internal/statements"
|
"xorm.io/xorm/v2/internal/json"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/internal/statements"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/log"
|
||||||
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrFieldIsNotExist columns does not exist
|
// ErrFieldIsNotExist columns does not exist
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setColumnInt(bean interface{}, col *schemas.Column, t int64) {
|
func setColumnInt(bean interface{}, col *schemas.Column, t int64) {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNeedDeletedCond delete needs less one condition error
|
// ErrNeedDeletedCond delete needs less one condition error
|
||||||
|
|
|
@ -11,11 +11,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/internal/statements"
|
"xorm.io/xorm/v2/internal/statements"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -13,17 +13,15 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrObjectIsNil return error of object is nil
|
||||||
// ErrObjectIsNil return error of object is nil
|
var ErrObjectIsNil = errors.New("object should not be nil")
|
||||||
ErrObjectIsNil = errors.New("object should not be nil")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Get retrieve one record from database, bean's non-empty fields
|
// Get retrieve one record from database, bean's non-empty fields
|
||||||
// will be as conditions
|
// will be as conditions
|
||||||
|
@ -66,7 +64,7 @@ func (session *Session) get(beans ...interface{}) (bool, error) {
|
||||||
return false, ErrObjectIsNil
|
return false, ErrObjectIsNil
|
||||||
}
|
}
|
||||||
|
|
||||||
var isStruct = beanValue.Elem().Kind() == reflect.Struct && !isPtrOfTime(beans[0])
|
isStruct := beanValue.Elem().Kind() == reflect.Struct && !isPtrOfTime(beans[0])
|
||||||
if isStruct {
|
if isStruct {
|
||||||
if err := session.statement.SetRefBean(beans[0]); err != nil {
|
if err := session.statement.SetRefBean(beans[0]); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -212,7 +210,7 @@ func (session *Session) getSlice(rows *core.Rows, types []*sql.ColumnType, field
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var needAppend = len(*t) == 0 // both support slice is empty or has been initlized
|
needAppend := len(*t) == 0 // both support slice is empty or has been initlized
|
||||||
for i, r := range res {
|
for i, r := range res {
|
||||||
if needAppend {
|
if needAppend {
|
||||||
*t = append(*t, r.(*sql.NullString).String)
|
*t = append(*t, r.(*sql.NullString).String)
|
||||||
|
@ -226,7 +224,7 @@ func (session *Session) getSlice(rows *core.Rows, types []*sql.ColumnType, field
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var needAppend = len(*t) == 0
|
needAppend := len(*t) == 0
|
||||||
for ii := range fields {
|
for ii := range fields {
|
||||||
s, err := convert.Interface2Interface(session.engine.DatabaseTZ, scanResults[ii])
|
s, err := convert.Interface2Interface(session.engine.DatabaseTZ, scanResults[ii])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -294,7 +292,7 @@ func (session *Session) cacheGet(bean interface{}, sqlStr string, args ...interf
|
||||||
table := session.statement.RefTable
|
table := session.statement.RefTable
|
||||||
ids, err := caches.GetCacheSql(cacher, tableName, newsql, args)
|
ids, err := caches.GetCacheSql(cacher, tableName, newsql, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var res = make([]string, len(table.PrimaryKeys))
|
res := make([]string, len(table.PrimaryKeys))
|
||||||
rows, err := session.NoCache().queryRows(newsql, args...)
|
rows, err := session.NoCache().queryRows(newsql, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrNoElementsOnSlice represents an error there is no element when insert
|
// ErrNoElementsOnSlice represents an error there is no element when insert
|
||||||
|
|
|
@ -7,7 +7,7 @@ package xorm
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IterFunc only use by Iterate
|
// IterFunc only use by Iterate
|
||||||
|
@ -64,15 +64,15 @@ func (session *Session) BufferSize(size int) *Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) bufferIterate(bean interface{}, fun IterFunc) error {
|
func (session *Session) bufferIterate(bean interface{}, fun IterFunc) error {
|
||||||
var bufferSize = session.statement.BufferSize
|
bufferSize := session.statement.BufferSize
|
||||||
var pLimitN = session.statement.LimitN
|
pLimitN := session.statement.LimitN
|
||||||
if pLimitN != nil && bufferSize > *pLimitN {
|
if pLimitN != nil && bufferSize > *pLimitN {
|
||||||
bufferSize = *pLimitN
|
bufferSize = *pLimitN
|
||||||
}
|
}
|
||||||
var start = session.statement.Start
|
start := session.statement.Start
|
||||||
v := utils.ReflectValue(bean)
|
v := utils.ReflectValue(bean)
|
||||||
sliceType := reflect.SliceOf(v.Type())
|
sliceType := reflect.SliceOf(v.Type())
|
||||||
var idx = 0
|
idx := 0
|
||||||
session.autoResetStatement = false
|
session.autoResetStatement = false
|
||||||
defer func() {
|
defer func() {
|
||||||
session.autoResetStatement = true
|
session.autoResetStatement = true
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/v2/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ping test if database is ok
|
// Ping test if database is ok
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/internal/statements"
|
"xorm.io/xorm/v2/internal/statements"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// enumerated all errors
|
// enumerated all errors
|
||||||
|
|
4
sync.go
4
sync.go
|
@ -7,8 +7,8 @@ package xorm
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SyncOptions struct {
|
type SyncOptions struct {
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrUnsupportedType represents an unsupported type error
|
// ErrUnsupportedType represents an unsupported type error
|
||||||
|
|
|
@ -10,10 +10,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tag struct {
|
type tag struct {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import "xorm.io/xorm/schemas"
|
import "xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
dbtypes = append(dbtypes, schemas.DAMENG)
|
dbtypes = append(dbtypes, schemas.DAMENG)
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
_ "gitee.com/travelliu/dm"
|
_ "gitee.com/travelliu/dm"
|
||||||
_ "github.com/denisenkom/go-mssqldb"
|
_ "github.com/denisenkom/go-mssqldb"
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreEngine(t *testing.T) {
|
func TestStoreEngine(t *testing.T) {
|
||||||
|
@ -716,7 +716,6 @@ func TestSyncWithOptions(t *testing.T) {
|
||||||
|
|
||||||
tableInfoFromStruct, _ := testEngine.TableInfo(&SyncWithOpts1{})
|
tableInfoFromStruct, _ := testEngine.TableInfo(&SyncWithOpts1{})
|
||||||
assert.ElementsMatch(t, getKeysFromMap(tableInfoFromStruct.Indexes), getKeysFromMap(getIndicesOfBeanFromDB(t, &SyncWithOpts1{})))
|
assert.ElementsMatch(t, getKeysFromMap(tableInfoFromStruct.Indexes), getKeysFromMap(getIndicesOfBeanFromDB(t, &SyncWithOpts1{})))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIndicesOfBeanFromDB(t *testing.T, bean interface{}) map[string]*schemas.Index {
|
func getIndicesOfBeanFromDB(t *testing.T, bean interface{}) map[string]*schemas.Index {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetExpr(t *testing.T) {
|
func TestSetExpr(t *testing.T) {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/v2/contexts"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/shopspring/decimal"
|
"github.com/shopspring/decimal"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IntId struct {
|
type IntId struct {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTransaction(t *testing.T) {
|
func TestTransaction(t *testing.T) {
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/internal/statements"
|
"xorm.io/xorm/v2/internal/statements"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpdateMap(t *testing.T) {
|
func TestUpdateMap(t *testing.T) {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tempUser struct {
|
type tempUser struct {
|
||||||
|
|
|
@ -14,11 +14,11 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/v2/caches"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/v2/dialects"
|
||||||
"xorm.io/xorm/log"
|
"xorm.io/xorm/v2/log"
|
||||||
"xorm.io/xorm/names"
|
"xorm.io/xorm/v2/names"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/v2/internal/utils"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,9 +13,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/v2/convert"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/v2/internal/json"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/v2/schemas"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue