Improved import, by group improt.

This commit is contained in:
houseme
2021-11-13 23:23:55 +08:00
parent 684fa9b9c9
commit be03b3cdda
286 changed files with 942 additions and 877 deletions

View File

@ -10,20 +10,17 @@ package gdb
import (
"context"
"database/sql"
"github.com/gogf/gf/v2/errors/gcode"
"time"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gcache"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/util/grand"
)
@ -455,7 +452,7 @@ func getConfigNodeByWeight(cg ConfigGroup) *ConfigNode {
max := 0
for i := 0; i < len(cg); i++ {
max = min + cg[i].Weight*100
//fmt.Printf("r: %d, min: %d, max: %d\n", r, min, max)
// fmt.Printf("r: %d, min: %d, max: %d\n", r, min, max)
if r >= min && r < max {
return &cg[i]
} else {

View File

@ -11,17 +11,16 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/internal/intlog"
"reflect"
"strings"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -8,11 +8,11 @@ package gdb
import (
"fmt"
"github.com/gogf/gf/v2/os/glog"
"sync"
"time"
"github.com/gogf/gf/v2/os/gcache"
"github.com/gogf/gf/v2/os/glog"
)
// Config is the configuration management object.

View File

@ -10,16 +10,12 @@ import (
"strings"
"time"
"github.com/gogf/gf/v2/util/gutil"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/encoding/gbinary"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gutil"
)
// convertFieldValueToLocalValue automatically checks and converts field value from database type

View File

@ -10,6 +10,7 @@ package gdb
import (
"context"
"fmt"
"github.com/gogf/gf/v2"
"github.com/gogf/gf/v2/net/gtrace"
"go.opentelemetry.io/otel"

View File

@ -9,17 +9,16 @@ package gdb
import (
"context"
"database/sql"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"reflect"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/guid"
"github.com/gogf/gf/v2/text/gregex"
)
// TX is the struct for transaction management.

View File

@ -10,9 +10,9 @@ package gdb
import (
"context"
"database/sql"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gtime"
)

View File

@ -15,16 +15,14 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"strconv"
"strings"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
)
// DriverMssql is the driver for SQL server database.

View File

@ -10,14 +10,14 @@ import (
"context"
"database/sql"
"fmt"
"net/url"
_ "github.com/go-sql-driver/mysql"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"net/url"
_ "github.com/go-sql-driver/mysql"
)
// DriverMysql is the driver for mysql database.

View File

@ -15,12 +15,12 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"reflect"
"strconv"
"strings"
"time"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/text/gregex"
@ -98,7 +98,7 @@ func (d *DriverOracle) DoCommit(ctx context.Context, link Link, sql string, args
if reflect.TypeOf(v).Kind() == reflect.String {
valueStr := gconv.String(v)
if gregex.IsMatchString(`^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$`, valueStr) {
//args[i] = fmt.Sprintf(`TO_DATE('%s','yyyy-MM-dd HH:MI:SS')`, valueStr)
// args[i] = fmt.Sprintf(`TO_DATE('%s','yyyy-MM-dd HH:MI:SS')`, valueStr)
args[i], _ = time.ParseInLocation("2006-01-02 15:04:05", valueStr, time.Local)
}
}

View File

@ -15,14 +15,13 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"strings"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
)
// DriverPgsql is the driver for postgresql database.

View File

@ -14,9 +14,9 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"strings"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gfile"

View File

@ -10,25 +10,23 @@ import (
"bytes"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"reflect"
"regexp"
"strings"
"time"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/empty"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gmeta"
"github.com/gogf/gf/v2/util/gutil"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gmeta"
"github.com/gogf/gf/v2/util/gutil"
)
// iString is the type assert api for String.

View File

@ -9,10 +9,10 @@ package gdb
import (
"context"
"fmt"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)
// Model is core struct implementing the DAO for ORM.

View File

@ -7,8 +7,9 @@
package gdb
import (
"github.com/gogf/gf/v2/internal/intlog"
"time"
"github.com/gogf/gf/v2/internal/intlog"
)
type CacheOption struct {

View File

@ -8,6 +8,7 @@ package gdb
import (
"fmt"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -9,8 +9,8 @@ package gdb
import (
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"

View File

@ -8,6 +8,7 @@ package gdb
import (
"fmt"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"

View File

@ -8,12 +8,12 @@ package gdb
import (
"database/sql"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/internal/utils"
"reflect"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"

View File

@ -8,15 +8,15 @@ package gdb
import (
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"reflect"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -8,6 +8,7 @@ package gdb
import (
"fmt"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"

View File

@ -9,11 +9,11 @@ package gdb
import (
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/internal/utils"
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"

View File

@ -9,9 +9,9 @@ package gdb
import (
"database/sql"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/internal/utils"

View File

@ -9,8 +9,8 @@ package gdb
import (
"context"
"database/sql"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
)

View File

@ -8,6 +8,7 @@ package gdb
import (
"database/sql"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/internal/empty"

View File

@ -7,10 +7,11 @@
package gdb
import (
"math"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/util/gconv"
"math"
)
// IsEmpty checks and returns whether `r` is empty.

View File

@ -8,13 +8,14 @@ package gdb
import (
"database/sql"
"reflect"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/structs"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gutil"
"reflect"
)
// ScanList converts `r` to struct slice which contains other complex struct attributes.

View File

@ -9,11 +9,11 @@ package gdb_test
import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -13,10 +13,9 @@ import (
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gconv"
)
func Test_Table_Relation_One(t *testing.T) {
@ -1368,19 +1367,19 @@ CREATE TABLE %s (
})
t.AssertNil(err)
// Detail.
//_, err = db.Insert(ctx, tableUserDetail, g.Map{
// _, err = db.Insert(ctx, tableUserDetail, g.Map{
// "uid": i,
// "address": fmt.Sprintf(`address_%d`, i),
//})
//t.AssertNil(err)
// })
// t.AssertNil(err)
// Scores.
//for j := 1; j <= 5; j++ {
// for j := 1; j <= 5; j++ {
// _, err = db.Insert(ctx, tableUserScores, g.Map{
// "uid": i,
// "score": j,
// })
// t.AssertNil(err)
//}
// }
}
})

View File

@ -8,13 +8,14 @@ package gdb_test
import (
"fmt"
"testing"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gmeta"
"testing"
)
/*
@ -1675,7 +1676,7 @@ func Test_Table_Relation_With_MultipleDepends1(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA *TableA
err := db.Model("table_a").WithAll().Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.AssertNE(tableA, nil)
t.Assert(tableA.Id, 1)
@ -1691,7 +1692,7 @@ func Test_Table_Relation_With_MultipleDepends1(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA []*TableA
err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.Assert(len(tableA), 2)
t.AssertNE(tableA[0].TableB, nil)
@ -1747,7 +1748,7 @@ func Test_Table_Relation_With_MultipleDepends2(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA *TableA
err := db.Model("table_a").WithAll().Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.AssertNE(tableA, nil)
t.Assert(tableA.Id, 1)
@ -1770,7 +1771,7 @@ func Test_Table_Relation_With_MultipleDepends2(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA []*TableA
err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.Assert(len(tableA), 2)
@ -1834,7 +1835,7 @@ func Test_Table_Relation_With_MultipleDepends_Embedded(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA *TableA
err := db.Model("table_a").WithAll().Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.AssertNE(tableA, nil)
t.Assert(tableA.Id, 1)
@ -1850,7 +1851,7 @@ func Test_Table_Relation_With_MultipleDepends_Embedded(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var tableA []*TableA
err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA)
//g.Dump(tableA)
// g.Dump(tableA)
t.AssertNil(err)
t.Assert(len(tableA), 2)
t.AssertNE(tableA[0].TableB, nil)
@ -1962,7 +1963,7 @@ PRIMARY KEY (id)
db.SetDebug(true)
defer db.SetDebug(false)
//gtest.C(t, func(t *gtest.T) {
// gtest.C(t, func(t *gtest.T) {
// var user *User
// err := db.Model(tableUser).WithAll().Where("id", 3).Scan(&user)
// t.AssertNil(err)
@ -1975,7 +1976,7 @@ PRIMARY KEY (id)
// t.Assert(user.UserScores[0].Score, 1)
// t.Assert(user.UserScores[4].UserID, 3)
// t.Assert(user.UserScores[4].Score, 5)
//})
// })
gtest.C(t, func(t *gtest.T) {
var user User
err := db.Model(tableUser).WithAll().Where("id", 4).Scan(&user)

View File

@ -7,10 +7,11 @@
package gdb_test
import (
"testing"
"github.com/go-sql-driver/mysql"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Instance(t *testing.T) {

View File

@ -9,11 +9,12 @@ package gdb
import (
"context"
"fmt"
"testing"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
const (
@ -497,7 +498,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Ptr(t *testing.T) {
},
}
err = r2.ScanList(&s, "Many", "One", "pid:Id")
//fmt.Printf("%+v", err)
// fmt.Printf("%+v", err)
t.AssertNil(err)
t.Assert(len(s), 2)
t.Assert(s[0].One.Name, "john")
@ -525,7 +526,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Ptr(t *testing.T) {
},
}
err = r3.ScanList(&s, "Many", "One", "pid:Id")
//fmt.Printf("%+v", err)
// fmt.Printf("%+v", err)
t.AssertNil(err)
t.Assert(len(s), 2)
t.Assert(s[0].One.Name, "john")
@ -601,7 +602,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Struct(t *testing.T) {
},
}
err = r2.ScanList(&s, "Many", "One", "pid:Id")
//fmt.Printf("%+v", err)
// fmt.Printf("%+v", err)
t.AssertNil(err)
t.Assert(len(s), 2)
t.Assert(s[0].One.Name, "john")
@ -629,7 +630,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Struct(t *testing.T) {
},
}
err = r3.ScanList(&s, "Many", "One", "pid:Id")
//fmt.Printf("%+v", err)
// fmt.Printf("%+v", err)
t.AssertNil(err)
t.Assert(len(s), 2)
t.Assert(s[0].One.Name, "john")

View File

@ -9,18 +9,17 @@ package gdb_test
import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/text/gstr"
"testing"
"time"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/encoding/gxml"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
)
func Test_DB_Ping(t *testing.T) {
@ -274,7 +273,7 @@ func Test_DB_Upadte_KeyFieldNameMapping(t *testing.T) {
}
// This is no longer used as the filter feature is automatically enabled from GoFrame v1.16.0.
//func Test_DB_Insert_KeyFieldNameMapping_Error(t *testing.T) {
// func Test_DB_Insert_KeyFieldNameMapping_Error(t *testing.T) {
// table := createTable()
// defer dropTable(table)
//
@ -297,7 +296,7 @@ func Test_DB_Upadte_KeyFieldNameMapping(t *testing.T) {
// _, err := db.Insert(ctx, table, data)
// t.AssertNE(err, nil)
// })
//}
// }
func Test_DB_InsertIgnore(t *testing.T) {
table := createInitTable()
@ -820,7 +819,7 @@ func Test_DB_ToJson(t *testing.T) {
gtest.Fatal(err)
}
//ToJson
// ToJson
resultJson, err := gjson.LoadContent(result.Json())
if err != nil {
gtest.Fatal(err)

View File

@ -11,23 +11,21 @@ import (
"context"
"database/sql"
"fmt"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/text/gstr"
"os"
"testing"
"time"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/util/gutil"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gutil"
)
func Test_Model_Insert(t *testing.T) {
@ -706,16 +704,16 @@ func Test_Model_Count(t *testing.T) {
t.AssertNil(err)
t.Assert(count, TableSize)
})
//gtest.C(t, func(t *gtest.T) {
// gtest.C(t, func(t *gtest.T) {
// count, err := db.Model(table).Fields("id myid").Where("id>8").Count()
// t.AssertNil(err)
// t.Assert(count, 2)
//})
//gtest.C(t, func(t *gtest.T) {
// })
// gtest.C(t, func(t *gtest.T) {
// count, err := db.Model(table).As("u1").LeftJoin(table, "u2", "u2.id=u1.id").Fields("u2.id u2id").Where("u1.id>8").Count()
// t.AssertNil(err)
// t.Assert(count, 2)
//})
// })
}
func Test_Model_Select(t *testing.T) {
@ -954,8 +952,8 @@ func Test_Model_StructsWithOrmTag(t *testing.T) {
)
})
//db.SetDebug(true)
//defer db.SetDebug(false)
// db.SetDebug(true)
// defer db.SetDebug(false)
gtest.C(t, func(t *gtest.T) {
type A struct {
Passport string
@ -1302,7 +1300,7 @@ func Test_Model_Where(t *testing.T) {
// complicated where 1
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
conditions := g.Map{
"nickname like ?": "%name%",
"id between ? and ?": g.Slice{1, 3},
@ -1317,7 +1315,7 @@ func Test_Model_Where(t *testing.T) {
})
// complicated where 2
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
conditions := g.Map{
"nickname like ?": "%name%",
"id between ? and ?": g.Slice{1, 3},
@ -1390,7 +1388,7 @@ func Test_Model_Where_ISNULL_1(t *testing.T) {
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
result, err := db.Model(table).Data("nickname", nil).Where("id", 2).Update()
t.AssertNil(err)
n, _ := result.RowsAffected()
@ -1409,7 +1407,7 @@ func Test_Model_Where_ISNULL_2(t *testing.T) {
// complicated one.
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
conditions := g.Map{
"nickname like ?": "%name%",
"id between ? and ?": g.Slice{1, 3},
@ -1638,7 +1636,7 @@ func Test_Model_WherePri(t *testing.T) {
// complicated where 1
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
conditions := g.Map{
"nickname like ?": "%name%",
"id between ? and ?": g.Slice{1, 3},
@ -1653,7 +1651,7 @@ func Test_Model_WherePri(t *testing.T) {
})
// complicated where 2
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
conditions := g.Map{
"nickname like ?": "%name%",
"id between ? and ?": g.Slice{1, 3},
@ -2212,7 +2210,7 @@ func Test_Model_Prefix(t *testing.T) {
}
func Test_Model_Schema1(t *testing.T) {
//db.SetDebug(true)
// db.SetDebug(true)
db.SetSchema(TestSchema1)
table := fmt.Sprintf(`%s_%s`, TableName, gtime.TimestampNanoStr())
@ -2291,7 +2289,7 @@ func Test_Model_Schema1(t *testing.T) {
}
func Test_Model_Schema2(t *testing.T) {
//db.SetDebug(true)
// db.SetDebug(true)
db.SetSchema(TestSchema1)
table := fmt.Sprintf(`%s_%s`, TableName, gtime.TimestampNanoStr())
@ -2956,7 +2954,7 @@ func Test_Model_Issue1002(t *testing.T) {
}
})
// where + time.Time arguments, +8.
//gtest.C(t, func(t *gtest.T) {
// gtest.C(t, func(t *gtest.T) {
// // Change current timezone to +8 zone.
// location, err := time.LoadLocation("Asia/Shanghai")
// t.AssertNil(err)
@ -2977,7 +2975,7 @@ func Test_Model_Issue1002(t *testing.T) {
// t.AssertNil(err)
// t.Assert(v.Int(), 1)
// }
//})
// })
}
func createTableForTimeZoneTest() string {
@ -3190,7 +3188,7 @@ func Test_Model_WhereOrBetween(t *testing.T) {
func Test_Model_WhereOrNotBetween(t *testing.T) {
table := createInitTable()
defer dropTable(table)
//db.SetDebug(true)
// db.SetDebug(true)
gtest.C(t, func(t *gtest.T) {
result, err := db.Model(table).WhereOrNotBetween("id", 1, 4).WhereOrNotBetween("id", 3, 5).OrderDesc("id").All()
t.AssertNil(err)

View File

@ -8,10 +8,11 @@ package gdb_test
import (
"fmt"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
// Using filter dose not affect the outside value inside function.
@ -107,7 +108,7 @@ func Test_Model_Embedded_Filter(t *testing.T) {
}
// This is no longer used as the filter feature is automatically enabled from GoFrame v1.16.0.
//func Test_Model_Insert_KeyFieldNameMapping_Error(t *testing.T) {
// func Test_Model_Insert_KeyFieldNameMapping_Error(t *testing.T) {
// table := createTable()
// defer dropTable(table)
//
@ -130,7 +131,7 @@ func Test_Model_Embedded_Filter(t *testing.T) {
// _, err := db.Model(table).Data(data).Insert()
// t.AssertNE(err, nil)
// })
//}
// }
func Test_Model_Fields_AutoFilterInJoinStatement(t *testing.T) {
gtest.C(t, func(t *gtest.T) {

View File

@ -7,8 +7,9 @@
package gdb_test
import (
"github.com/gogf/gf/v2/test/gtest"
"testing"
"github.com/gogf/gf/v2/test/gtest"
)
func Test_Model_Insert_Data_ForDao(t *testing.T) {

View File

@ -7,10 +7,11 @@
package gdb_test
import (
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Model_LeftJoinOnField(t *testing.T) {

View File

@ -8,6 +8,9 @@ package gdb_test
import (
"database/sql"
"reflect"
"testing"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
@ -16,8 +19,6 @@ import (
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"reflect"
"testing"
)
func Test_Model_Embedded_Insert(t *testing.T) {
@ -466,7 +467,7 @@ func Test_Scan_AutoFilteringByStructAttributes(t *testing.T) {
Id int
Passport string
}
//db.SetDebug(true)
// db.SetDebug(true)
gtest.C(t, func(t *gtest.T) {
var user *User
err := db.Model(table).OrderAsc("id").Scan(&user)

View File

@ -7,9 +7,9 @@
package gdb_test
import (
"github.com/gogf/gf/v2/frame/g"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -7,10 +7,11 @@
package gdb_test
import (
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Model_WherePrefix(t *testing.T) {

View File

@ -7,10 +7,10 @@
package gdb_test
import (
"github.com/gogf/gf/v2/frame/g"
"testing"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -8,12 +8,11 @@ package gdb_test
import (
"fmt"
"github.com/gogf/gf/v2/os/gtime"
"testing"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)
@ -566,7 +565,7 @@ CREATE TABLE %s (
defer dropTable(table2)
gtest.C(t, func(t *gtest.T) {
//db.SetDebug(true)
// db.SetDebug(true)
dataInsert1 := g.Map{
"id": 1,
"name": "name_1",
@ -620,7 +619,7 @@ CREATE TABLE %s (
gtest.Error(err)
}
defer dropTable(table)
//db.SetDebug(true)
// db.SetDebug(true)
// Add datas.
gtest.C(t, func(t *gtest.T) {
for i := 1; i <= 10; i++ {
@ -663,8 +662,8 @@ CREATE TABLE %s (
}
defer dropTable(table)
//db.SetDebug(true)
//defer db.SetDebug(false)
// db.SetDebug(true)
// defer db.SetDebug(false)
type Entity struct {
Id uint64 `orm:"id,primary" json:"id"`

View File

@ -9,13 +9,12 @@ package gdb_test
import (
"context"
"fmt"
"github.com/gogf/gf/v2/os/gctx"
"testing"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)
@ -955,8 +954,8 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) {
table := createTable()
defer dropTable(table)
//db.SetDebug(true)
//defer db.SetDebug(false)
// db.SetDebug(true)
// defer db.SetDebug(false)
gtest.C(t, func(t *gtest.T) {
var (

View File

@ -8,11 +8,10 @@ package gdb_test
import (
"fmt"
"github.com/gogf/gf/v2/os/gtime"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -7,9 +7,9 @@
package gdb_test
import (
"github.com/gogf/gf/v2/frame/g"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -7,8 +7,9 @@
package gdb
import (
"github.com/gogf/gf/v2/test/gtest"
"testing"
"github.com/gogf/gf/v2/test/gtest"
)
func Test_Oracle_parseSql(t *testing.T) {

View File

@ -8,6 +8,7 @@ package gredis
import (
"context"
"github.com/gogf/gf/v2/container/gvar"
)

View File

@ -8,9 +8,10 @@ package gredis
import (
"context"
"time"
"github.com/go-redis/redis/v8"
"github.com/gogf/gf/v2/text/gstr"
"time"
)
// AdapterGoRedis is an implement of Adapter using go-redis.

View File

@ -8,6 +8,7 @@ package gredis
import (
"context"
"github.com/go-redis/redis/v8"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/text/gstr"

View File

@ -9,12 +9,12 @@ package gredis
import (
"context"
"crypto/tls"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -8,6 +8,7 @@ package gredis
import (
"context"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/internal/intlog"
)

View File

@ -8,6 +8,7 @@ package gredis
import (
"context"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

View File

@ -8,11 +8,12 @@ package gredis
import (
"context"
"reflect"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/os/gtime"
"reflect"
)
// RedisConn is a connection of redis client.

View File

@ -9,6 +9,7 @@ package gredis
import (
"context"
"fmt"
"github.com/gogf/gf/v2"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/net/gtrace"

View File

@ -9,6 +9,7 @@ package gredis_test
import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gutil"

View File

@ -7,11 +7,12 @@
package gredis_test
import (
"testing"
"time"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
"testing"
"time"
)
func Test_ConfigFromMap(t *testing.T) {

View File

@ -8,9 +8,10 @@ package gredis_test
import (
"context"
"testing"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
var (

View File

@ -7,18 +7,17 @@
package gredis_test
import (
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/guid"
"github.com/gogf/gf/v2/util/gutil"
"testing"
"time"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/guid"
"github.com/gogf/gf/v2/util/gutil"
)
var (