mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
revert from int64 to int for returning value of Count (#2378)
* revert from int64 to int for returning value of Count * up * up * up
This commit is contained in:
parent
87cb1c9b8e
commit
31e44062a8
1
.github/workflows/build_and_test.sh
vendored
1
.github/workflows/build_and_test.sh
vendored
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
GOARCH=${{ matrix.goarch }}
|
||||
for file in `find . -name go.mod`; do
|
||||
dirpath=$(dirname $file)
|
||||
echo $dirpath
|
||||
|
4
.github/workflows/gf.yml
vendored
4
.github/workflows/gf.yml
vendored
@ -180,7 +180,9 @@ jobs:
|
||||
run: bash .github/workflows/before_script.sh
|
||||
|
||||
- name: Build & Test
|
||||
run: bash .github/workflows/build_and_test.sh
|
||||
run: |
|
||||
GOARCH=${{ matrix.goarch }}
|
||||
bash .github/workflows/build_and_test.sh
|
||||
|
||||
- name: Stop Redis Cluster Containers
|
||||
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" down
|
||||
|
@ -283,9 +283,9 @@ func TestDriverClickhouse_Insert(t *testing.T) {
|
||||
Created time.Time `orm:"created"`
|
||||
}
|
||||
var (
|
||||
insertUrl = "https://goframe.org"
|
||||
total int64 = 0
|
||||
item = insertItem{
|
||||
insertUrl = "https://goframe.org"
|
||||
total = 0
|
||||
item = insertItem{
|
||||
Duration: 1,
|
||||
Url: insertUrl,
|
||||
Created: time.Now(),
|
||||
|
@ -81,7 +81,7 @@ func Test_Master_Slave(t *testing.T) {
|
||||
_, err = masterSlaveDB.Model(table).Data(array).Insert()
|
||||
t.AssertNil(err)
|
||||
|
||||
var count int64
|
||||
var count int
|
||||
// Auto slave.
|
||||
count, err = masterSlaveDB.Model(table).Count()
|
||||
t.AssertNil(err)
|
||||
|
@ -118,7 +118,7 @@ type DB interface {
|
||||
GetOne(ctx context.Context, sql string, args ...interface{}) (Record, error) // See Core.GetOne.
|
||||
GetValue(ctx context.Context, sql string, args ...interface{}) (Value, error) // See Core.GetValue.
|
||||
GetArray(ctx context.Context, sql string, args ...interface{}) ([]Value, error) // See Core.GetArray.
|
||||
GetCount(ctx context.Context, sql string, args ...interface{}) (int64, error) // See Core.GetCount.
|
||||
GetCount(ctx context.Context, sql string, args ...interface{}) (int, error) // See Core.GetCount.
|
||||
GetScan(ctx context.Context, objPointer interface{}, sql string, args ...interface{}) error // See Core.GetScan.
|
||||
Union(unions ...*Model) *Model // See Core.Union.
|
||||
UnionAll(unions ...*Model) *Model // See Core.UnionAll.
|
||||
|
@ -230,7 +230,7 @@ func (c *Core) GetValue(ctx context.Context, sql string, args ...interface{}) (V
|
||||
}
|
||||
|
||||
// GetCount queries and returns the count from database.
|
||||
func (c *Core) GetCount(ctx context.Context, sql string, args ...interface{}) (int64, error) {
|
||||
func (c *Core) GetCount(ctx context.Context, sql string, args ...interface{}) (int, error) {
|
||||
// If the query fields do not contain function "COUNT",
|
||||
// it replaces the sql string and adds the "COUNT" function to the fields.
|
||||
if !gregex.IsMatchString(`(?i)SELECT\s+COUNT\(.+\)\s+FROM`, sql) {
|
||||
@ -240,7 +240,7 @@ func (c *Core) GetCount(ctx context.Context, sql string, args ...interface{}) (i
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return value.Int64(), nil
|
||||
return value.Int(), nil
|
||||
}
|
||||
|
||||
// Union does "(SELECT xxx FROM xxx) UNION (SELECT xxx FROM xxx) ..." statement.
|
||||
|
@ -308,7 +308,7 @@ func (m *Model) Value(fieldsAndWhere ...interface{}) (Value, error) {
|
||||
// Count does "SELECT COUNT(x) FROM ..." statement for the model.
|
||||
// The optional parameter `where` is the same as the parameter of Model.Where function,
|
||||
// see Model.Where.
|
||||
func (m *Model) Count(where ...interface{}) (int64, error) {
|
||||
func (m *Model) Count(where ...interface{}) (int, error) {
|
||||
var ctx = m.GetCtx()
|
||||
if len(where) > 0 {
|
||||
return m.Where(where[0], where[1:]...).Count()
|
||||
@ -324,7 +324,7 @@ func (m *Model) Count(where ...interface{}) (int64, error) {
|
||||
if internalData := m.db.GetCore().GetInternalCtxDataFromCtx(ctx); internalData != nil {
|
||||
record := all[0]
|
||||
if v, ok := record[internalData.FirstResultColumn]; ok {
|
||||
return v.Int64(), nil
|
||||
return v.Int(), nil
|
||||
}
|
||||
}
|
||||
return 0, gerror.NewCode(
|
||||
@ -336,7 +336,7 @@ func (m *Model) Count(where ...interface{}) (int64, error) {
|
||||
}
|
||||
|
||||
// CountColumn does "SELECT COUNT(x) FROM ..." statement for the model.
|
||||
func (m *Model) CountColumn(column string) (int64, error) {
|
||||
func (m *Model) CountColumn(column string) (int, error) {
|
||||
if len(column) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
@ -112,21 +112,16 @@ func TestCron_Add_FixedPattern(t *testing.T) {
|
||||
func doTestCronAddFixedPattern(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
now = time.Now()
|
||||
cron = gcron.New()
|
||||
array = garray.New(true)
|
||||
minutes = now.Minute()
|
||||
seconds = now.Second() + 2
|
||||
now = time.Now()
|
||||
cron = gcron.New()
|
||||
array = garray.New(true)
|
||||
expect = now.Add(time.Second * 2)
|
||||
)
|
||||
defer cron.Close()
|
||||
|
||||
if seconds >= 60 {
|
||||
seconds %= 60
|
||||
minutes++
|
||||
}
|
||||
var pattern = fmt.Sprintf(
|
||||
`%d %d %d %d %d %s`,
|
||||
seconds, minutes, now.Hour(), now.Day(), now.Month(), now.Weekday().String(),
|
||||
expect.Second(), expect.Minute(), expect.Hour(), expect.Day(), expect.Month(), expect.Weekday().String(),
|
||||
)
|
||||
cron.SetLogger(g.Log())
|
||||
g.Log().Debugf(ctx, `pattern: %s`, pattern)
|
||||
|
@ -2,5 +2,5 @@ package gf
|
||||
|
||||
const (
|
||||
// VERSION is the current GoFrame version.
|
||||
VERSION = "v2.2.5"
|
||||
VERSION = "v2.2.6"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user