This commit is contained in:
Lunny Xiao 2023-10-27 15:32:38 +08:00
parent 6ef0a7798f
commit 41154ea9ae
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
78 changed files with 248 additions and 223 deletions

View File

@ -12,7 +12,7 @@ import (
"strings"
"time"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
const (

View File

@ -8,7 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
func TestLRUCache(t *testing.T) {
@ -40,7 +40,7 @@ func TestLRUCache(t *testing.T) {
obj2 := cacher.GetBean(tableName, sid)
assert.Nil(t, obj2)
var obj = new(CacheObject1)
obj := new(CacheObject1)
cacher.PutBean(tableName, sid, obj)
obj3 := cacher.GetBean(tableName, sid)
assert.EqualValues(t, obj, obj3)

View File

@ -11,7 +11,7 @@ import (
"strings"
"time"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/v2/internal/utils"
)
// String2Time converts a string to time with original location

View File

@ -13,15 +13,13 @@ import (
"regexp"
"sync"
"xorm.io/xorm/contexts"
"xorm.io/xorm/log"
"xorm.io/xorm/names"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/names"
)
var (
// DefaultCacheSize sets the default cache size
DefaultCacheSize = 200
)
// DefaultCacheSize sets the default cache size
var DefaultCacheSize = 200
// MapToSlice map query and struct as sql and args
func MapToSlice(query string, mp interface{}) (string, []interface{}, error) {
@ -79,9 +77,7 @@ type cacheStruct struct {
idx int
}
var (
_ QueryExecuter = &DB{}
)
var _ QueryExecuter = &DB{}
// DB is a wrap of sql.DB with extra contents
type DB struct {
@ -234,9 +230,7 @@ func (db *DB) QueryRowStruct(query string, st interface{}) *Row {
return db.QueryRowStructContext(context.Background(), query, st)
}
var (
re = regexp.MustCompile(`[?](\w+)`)
)
var re = regexp.MustCompile(`[?](\w+)`)
// ExecMapContext exec map with context.ContextHook
// insert into (name) values (?)

View File

@ -11,7 +11,7 @@ import (
"testing"
"time"
"xorm.io/xorm/names"
"xorm.io/xorm/v2/names"
_ "github.com/go-sql-driver/mysql"
_ "github.com/mattn/go-sqlite3"
@ -625,7 +625,8 @@ func TestExecStruct(t *testing.T) {
t.Error(err)
}
user := User{Name: "xlw",
user := User{
Name: "xlw",
Title: "tester",
Age: 1.2,
Alias: "lunny",
@ -670,7 +671,8 @@ func BenchmarkExecStruct(b *testing.B) {
b.StartTimer()
user := User{Name: "xlw",
user := User{
Name: "xlw",
Title: "tester",
Age: 1.2,
Alias: "lunny",

View File

@ -10,7 +10,7 @@ import (
"errors"
"reflect"
"xorm.io/xorm/contexts"
"xorm.io/xorm/v2/contexts"
)
// Stmt reprents a stmt objects

View File

@ -8,12 +8,10 @@ import (
"context"
"database/sql"
"xorm.io/xorm/contexts"
"xorm.io/xorm/v2/contexts"
)
var (
_ QueryExecuter = &Tx{}
)
var _ QueryExecuter = &Tx{}
// Tx represents a transaction
type Tx struct {

View File

@ -13,10 +13,10 @@ import (
"strconv"
"strings"
"xorm.io/xorm/convert"
"xorm.io/xorm/core"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
func init() {

View File

@ -10,8 +10,8 @@ import (
"strings"
"time"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
// URI represents an uri to visit database

View File

@ -9,7 +9,7 @@ import (
"fmt"
"time"
"xorm.io/xorm/core"
"xorm.io/xorm/v2/core"
)
// ScanContext represents a context when Scan
@ -31,9 +31,7 @@ type Driver interface {
Scan(*ScanContext, *core.Rows, []*sql.ColumnType, ...interface{}) error
}
var (
drivers = map[string]Driver{}
)
var drivers = map[string]Driver{}
// RegisterDriver register a driver
func RegisterDriver(driverName string, driver Driver) {

View File

@ -13,8 +13,8 @@ import (
"strconv"
"strings"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -14,8 +14,8 @@ import (
"strings"
"time"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -13,8 +13,8 @@ import (
"strconv"
"strings"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -13,8 +13,8 @@ import (
"strconv"
"strings"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
// from http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html

View File

@ -12,8 +12,8 @@ import (
"regexp"
"strings"
"xorm.io/xorm/core"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -9,9 +9,9 @@ import (
"reflect"
"strings"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
// TableNameWithSchema will add schema prefix on table name if possible

View File

@ -7,7 +7,7 @@ package dialects
import (
"testing"
"xorm.io/xorm/names"
"xorm.io/xorm/v2/names"
"github.com/stretchr/testify/assert"
)

View File

@ -8,7 +8,7 @@ import (
"strings"
"time"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// FormatColumnTime format column time

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
type dialect struct {

View File

@ -17,15 +17,15 @@ import (
"strings"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/contexts"
"xorm.io/xorm/core"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/log"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/tags"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
"xorm.io/xorm/v2/tags"
)
// Engine is the major struct of xorm, it means a database manager.

View File

@ -8,11 +8,11 @@ import (
"context"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/contexts"
"xorm.io/xorm/dialects"
"xorm.io/xorm/log"
"xorm.io/xorm/names"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/names"
)
// EngineGroup defines an engine group

43
go.mod
View File

@ -1,13 +1,12 @@
module xorm.io/xorm
module xorm.io/xorm/v2
go 1.16
go 1.18
require (
gitee.com/travelliu/dm v1.8.11192
github.com/denisenkom/go-mssqldb v0.12.3
github.com/go-sql-driver/mysql v1.7.0
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/json-iterator/go v1.1.12
github.com/lib/pq v1.10.7
@ -18,4 +17,42 @@ require (
github.com/ziutek/mymysql v1.5.4
modernc.org/sqlite v1.20.4
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
View File

@ -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/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
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/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
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/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
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/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=
@ -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=
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/xorm v1.3.4 h1:vWFKzR3DhGUDl5b4srhUjhDwjxkZAc4C7BFszpu0swI=
xorm.io/xorm v1.3.4/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=

View File

@ -10,12 +10,12 @@ import (
"reflect"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/contexts"
"xorm.io/xorm/dialects"
"xorm.io/xorm/log"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
// Interface defines the interface which Engine, EngineGroup and Session will implementate.

View File

@ -9,8 +9,8 @@ import (
"strconv"
"strings"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
// ConvertIDSQL converts SQL with id

View File

@ -7,7 +7,7 @@ package statements
import (
"strings"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
type columnMap []string

View File

@ -6,7 +6,7 @@ package statements
import (
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
type QuoteReplacer struct {

View File

@ -10,8 +10,8 @@ import (
"time"
"xorm.io/builder"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
func (statement *Statement) writeDeleteOrder(w *builder.BytesWriter) error {

View File

@ -9,7 +9,7 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// ErrUnsupportedExprType represents an error with unsupported express type
@ -59,7 +59,7 @@ func (expr *Expr) WriteArgs(w *builder.BytesWriter) error {
type exprParams []Expr
func (exprs exprParams) ColNames() []string {
var cols = make([]string, 0, len(exprs))
cols := make([]string, 0, len(exprs))
for _, expr := range exprs {
cols = append(cols, expr.ColName)
}

View File

@ -10,8 +10,8 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
func (statement *Statement) writeInsertOutput(buf *strings.Builder, table *schemas.Table) error {

View File

@ -9,9 +9,9 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN

View File

@ -9,7 +9,7 @@ import (
"fmt"
"xorm.io/builder"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/v2/internal/utils"
)
func (statement *Statement) writePagination(bw *builder.BytesWriter) error {

View File

@ -9,7 +9,7 @@ import (
"reflect"
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
var (
@ -91,7 +91,7 @@ func (statement *Statement) ProcessIDParam() error {
}
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]})
}
return nil

View File

@ -11,7 +11,7 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// GenQuerySQL generate query SQL

View File

@ -8,7 +8,7 @@ import (
"fmt"
"strings"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// Select replace select

View File

@ -14,13 +14,13 @@ import (
"time"
"xorm.io/builder"
"xorm.io/xorm/contexts"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/tags"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/json"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
"xorm.io/xorm/v2/tags"
)
var (

View File

@ -6,7 +6,7 @@ package statements
import (
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// WriteArg writes an arg

View File

@ -12,11 +12,11 @@ import (
"time"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/caches"
"xorm.io/xorm/dialects"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/tags"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
"xorm.io/xorm/v2/tags"
_ "github.com/mattn/go-sqlite3"
)

View File

@ -9,7 +9,7 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
// TableName return current tableName

View File

@ -12,11 +12,11 @@ import (
"time"
"xorm.io/builder"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/json"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion, includeUpdated, includeNil,

View File

@ -12,10 +12,10 @@ import (
"reflect"
"time"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/json"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -7,7 +7,7 @@ package log
import (
"fmt"
"xorm.io/xorm/contexts"
"xorm.io/xorm/v2/contexts"
)
// LogContext represents a log context
@ -35,9 +35,7 @@ type ContextLogger interface {
IsShowSQL() bool
}
var (
_ ContextLogger = &LoggerAdapter{}
)
var _ ContextLogger = &LoggerAdapter{}
// enumerate all the context keys
var (

View File

@ -10,7 +10,7 @@ import (
"reflect"
"xorm.io/builder"
"xorm.io/xorm/core"
"xorm.io/xorm/v2/core"
)
// Rows rows wrapper a rows to

View File

@ -11,10 +11,10 @@ import (
"reflect"
"time"
"xorm.io/xorm/convert"
"xorm.io/xorm/core"
"xorm.io/xorm/dialects"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/schemas"
)
// genScanResultsByBeanNullabale generates scan result

View File

@ -8,7 +8,7 @@ import (
"bytes"
"encoding/gob"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/v2/internal/utils"
)
// PK represents primary key values

View File

@ -16,13 +16,14 @@ import (
"io"
"reflect"
"strconv"
"xorm.io/xorm/contexts"
"xorm.io/xorm/convert"
"xorm.io/xorm/core"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/internal/statements"
"xorm.io/xorm/log"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/internal/json"
"xorm.io/xorm/v2/internal/statements"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/schemas"
)
// ErrFieldIsNotExist columns does not exist

View File

@ -9,7 +9,7 @@ import (
"strings"
"time"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
func setColumnInt(bean interface{}, col *schemas.Column, t int64) {

View File

@ -9,8 +9,8 @@ import (
"strconv"
"xorm.io/builder"
"xorm.io/xorm/caches"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/schemas"
)
// ErrNeedDeletedCond delete needs less one condition error

View File

@ -11,11 +11,11 @@ import (
"strings"
"xorm.io/builder"
"xorm.io/xorm/caches"
"xorm.io/xorm/convert"
"xorm.io/xorm/internal/statements"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/internal/statements"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
const (

View File

@ -13,17 +13,15 @@ import (
"strconv"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/convert"
"xorm.io/xorm/core"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/core"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
var (
// ErrObjectIsNil return error of object is nil
ErrObjectIsNil = errors.New("object should not be nil")
)
// ErrObjectIsNil return error of object is nil
var ErrObjectIsNil = errors.New("object should not be nil")
// Get retrieve one record from database, bean's non-empty fields
// will be as conditions
@ -66,7 +64,7 @@ func (session *Session) get(beans ...interface{}) (bool, error) {
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 err := session.statement.SetRefBean(beans[0]); err != nil {
return false, err
@ -212,7 +210,7 @@ func (session *Session) getSlice(rows *core.Rows, types []*sql.ColumnType, field
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 {
if needAppend {
*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 {
return err
}
var needAppend = len(*t) == 0
needAppend := len(*t) == 0
for ii := range fields {
s, err := convert.Interface2Interface(session.engine.DatabaseTZ, scanResults[ii])
if err != nil {
@ -294,7 +292,7 @@ func (session *Session) cacheGet(bean interface{}, sqlStr string, args ...interf
table := session.statement.RefTable
ids, err := caches.GetCacheSql(cacher, tableName, newsql, args)
if err != nil {
var res = make([]string, len(table.PrimaryKeys))
res := make([]string, len(table.PrimaryKeys))
rows, err := session.NoCache().queryRows(newsql, args...)
if err != nil {
return false, err

View File

@ -13,10 +13,10 @@ import (
"time"
"xorm.io/builder"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
// ErrNoElementsOnSlice represents an error there is no element when insert

View File

@ -7,7 +7,7 @@ package xorm
import (
"reflect"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/v2/internal/utils"
)
// 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 {
var bufferSize = session.statement.BufferSize
var pLimitN = session.statement.LimitN
bufferSize := session.statement.BufferSize
pLimitN := session.statement.LimitN
if pLimitN != nil && bufferSize > *pLimitN {
bufferSize = *pLimitN
}
var start = session.statement.Start
start := session.statement.Start
v := utils.ReflectValue(bean)
sliceType := reflect.SliceOf(v.Type())
var idx = 0
idx := 0
session.autoResetStatement = false
defer func() {
session.autoResetStatement = true

View File

@ -8,7 +8,7 @@ import (
"database/sql"
"strings"
"xorm.io/xorm/core"
"xorm.io/xorm/v2/core"
)
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {

View File

@ -13,8 +13,8 @@ import (
"os"
"strings"
"xorm.io/xorm/dialects"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/internal/utils"
)
// Ping test if database is ok

View File

@ -8,9 +8,9 @@ import (
"reflect"
"xorm.io/builder"
"xorm.io/xorm/internal/statements"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/statements"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
// enumerated all errors

View File

@ -7,8 +7,8 @@ package xorm
import (
"strings"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/schemas"
)
type SyncOptions struct {

View File

@ -14,11 +14,11 @@ import (
"time"
"unicode"
"xorm.io/xorm/caches"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
// ErrUnsupportedType represents an unsupported type error

View File

@ -10,10 +10,10 @@ import (
"testing"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/dialects"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)

View File

@ -11,7 +11,7 @@ import (
"strings"
"time"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
type tag struct {

View File

@ -8,7 +8,7 @@ import (
"testing"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/v2/caches"
"github.com/stretchr/testify/assert"
)

View File

@ -7,7 +7,7 @@
package tests
import "xorm.io/xorm/schemas"
import "xorm.io/xorm/v2/schemas"
func init() {
dbtypes = append(dbtypes, schemas.DAMENG)

View File

@ -8,8 +8,8 @@ import (
"testing"
"xorm.io/xorm"
"xorm.io/xorm/log"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)

View File

@ -12,7 +12,7 @@ import (
"time"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
_ "gitee.com/travelliu/dm"
_ "github.com/denisenkom/go-mssqldb"

View File

@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/assert"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
func TestStoreEngine(t *testing.T) {
@ -716,7 +716,6 @@ func TestSyncWithOptions(t *testing.T) {
tableInfoFromStruct, _ := testEngine.TableInfo(&SyncWithOpts1{})
assert.ElementsMatch(t, getKeysFromMap(tableInfoFromStruct.Indexes), getKeysFromMap(getIndicesOfBeanFromDB(t, &SyncWithOpts1{})))
}
func getIndicesOfBeanFromDB(t *testing.T, bean interface{}) map[string]*schemas.Index {

View File

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
func TestSetExpr(t *testing.T) {

View File

@ -9,8 +9,8 @@ import (
"testing"
"time"
"xorm.io/xorm/caches"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)

View File

@ -10,9 +10,9 @@ import (
"xorm.io/builder"
"xorm.io/xorm"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)

View File

@ -13,10 +13,10 @@ import (
"time"
"xorm.io/xorm"
"xorm.io/xorm/contexts"
"xorm.io/xorm/convert"
"xorm.io/xorm/dialects"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/contexts"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/schemas"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"

View File

@ -11,7 +11,7 @@ import (
"time"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)

View File

@ -10,7 +10,7 @@ import (
"time"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
)
type IntId struct {

View File

@ -12,7 +12,7 @@ import (
"xorm.io/builder"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)
@ -493,4 +493,4 @@ func TestRowsReset(t *testing.T) {
assert.EqualValues(t, "4", rrs[0].Name)
assert.EqualValues(t, "5", rrs[1].Name)
assert.EqualValues(t, "6", rrs[2].Name)
}
}

View File

@ -9,7 +9,7 @@ import (
"testing"
"time"
"xorm.io/xorm/convert"
"xorm.io/xorm/v2/convert"
"github.com/stretchr/testify/assert"
)

View File

@ -10,8 +10,8 @@ import (
"time"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/names"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/names"
)
func TestTransaction(t *testing.T) {

View File

@ -12,10 +12,10 @@ import (
"github.com/stretchr/testify/assert"
"xorm.io/xorm"
"xorm.io/xorm/internal/statements"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/statements"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
func TestUpdateMap(t *testing.T) {

View File

@ -12,9 +12,9 @@ import (
"time"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/internal/utils"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
type tempUser struct {

View File

@ -14,11 +14,11 @@ import (
"testing"
"xorm.io/xorm"
"xorm.io/xorm/caches"
"xorm.io/xorm/dialects"
"xorm.io/xorm/log"
"xorm.io/xorm/names"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/caches"
"xorm.io/xorm/v2/dialects"
"xorm.io/xorm/v2/log"
"xorm.io/xorm/v2/names"
"xorm.io/xorm/v2/schemas"
)
var (

View File

@ -11,9 +11,9 @@ import (
"testing"
"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"
)

View File

@ -13,9 +13,9 @@ import (
"testing"
"xorm.io/xorm"
"xorm.io/xorm/convert"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/schemas"
"xorm.io/xorm/v2/convert"
"xorm.io/xorm/v2/internal/json"
"xorm.io/xorm/v2/schemas"
"github.com/stretchr/testify/assert"
)