Skip to content

Commit

Permalink
Merge branch 'master' into fix/#2924
Browse files Browse the repository at this point in the history
  • Loading branch information
hailaz authored Dec 6, 2023
2 parents 26b53a5 + ee2cf92 commit 432ab95
Show file tree
Hide file tree
Showing 43 changed files with 192 additions and 117 deletions.
18 changes: 11 additions & 7 deletions cmd/gf/gfcmd/gfcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
package gfcmd

import (
_ "github.com/gogf/gf/cmd/gf/v2/internal/packed"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

"context"
"runtime"

"github.com/gogf/gf/cmd/gf/v2/internal/cmd"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/allyes"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcfg"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gstr"

"github.com/gogf/gf/cmd/gf/v2/internal/cmd"
_ "github.com/gogf/gf/cmd/gf/v2/internal/packed"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/allyes"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
)

const (
Expand Down Expand Up @@ -99,6 +100,9 @@ func GetCommand(ctx context.Context) (*Command, error) {

// zsh alias "git fetch" conflicts checks.
func handleZshAlias() {
if runtime.GOOS == "windows" {
return
}
if home, err := gfile.Home(); err == nil {
zshPath := gfile.Join(home, ".zshrc")
if gfile.Exists(zshPath) {
Expand Down
14 changes: 7 additions & 7 deletions cmd/gf/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2
go 1.18

require (
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.7
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.6.0-beta
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.6.0-beta
github.com/gogf/gf/v2 v2.6.0-beta
github.com/minio/selfupdate v0.6.0
github.com/olekukonko/tablewriter v0.0.5
golang.org/x/mod v0.9.0
Expand Down
14 changes: 0 additions & 14 deletions cmd/gf/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.6 h1:yziPSf9AycEWphv9WiNjcRAVPOJtUauMMvP6pHQB4jY=
github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.5.6/go.mod h1:yOlpwhFXgW+P2sf4goA20PUtxdVLliBx4dJRyJeOtto=
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.6 h1:LGQIe5IvYVr4hZ/vUAFiqWssxE7QeILyVPJ9swo1Cmk=
github.com/gogf/gf/contrib/drivers/mssql/v2 v2.5.6/go.mod h1:EcF8v8jqCV61/YqN6DXxdo3kh8waGmEj6WpFqbLkkrM=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6 h1:oR9F4LVoKa/fjf/o6Y/CQRNiYy35Bszo07WwvMWYMxo=
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.6/go.mod h1:gvHSRqCpv2c+N0gDHsEldHgU/yM9tcCBdIEKZ32/TaE=
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.6 h1:3Y3lEoO9SoG1AmfaKjgTsDt93+T2q/qTMog8wBvIIGM=
github.com/gogf/gf/contrib/drivers/oracle/v2 v2.5.6/go.mod h1:cR3lFoU6ZtSaMQ3DpCJwWnYW6EvHPYGGeqv/kzgH4gw=
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.6 h1:0WHVzqITqIBu/NNPXt3tN2eiWAGiNjs9sg6wh+WbUvY=
github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.5.6/go.mod h1:qZCTNQ0n2gHcuBwM9wUl3pelync3xK0gTnChJZD6f0I=
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.6 h1:6clfLvFoHXHdw+skmXg4yxw+cLwgAG8gRiS/6f9Y9Xc=
github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.5.6/go.mod h1:QV6Rrj+4G4OaJVkP9XXRZ1LWL+ls6qH7ebeMcxsulqA=
github.com/gogf/gf/v2 v2.5.6 h1:a1UK1yUP3s+l+vPxmV91+8gTarAP9b1IEOw0W7LNl6E=
github.com/gogf/gf/v2 v2.5.6/go.mod h1:17K/gBYrp0bHGC3XYC7bSPoywmZ6MrZHrZakTfh4eIQ=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
Expand Down
16 changes: 10 additions & 6 deletions cmd/gf/internal/cmd/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func init() {
type (
cRunInput struct {
g.Meta `name:"run"`
File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"`
Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"`
Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"`
Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"`
WatchPaths string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"`
File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"`
Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"`
Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"`
Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"`
WatchPaths []string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"`
}
cRunOutput struct{}
)
Expand All @@ -97,12 +97,16 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err
mlog.Fatalf(`command "go" not found in your environment, please install golang first to proceed this command`)
}

if len(in.WatchPaths) == 1 {
in.WatchPaths = strings.Split(in.WatchPaths[0], ",")
}

app := &cRunApp{
File: in.File,
Path: in.Path,
Options: in.Extra,
Args: in.Args,
WatchPaths: strings.Split(in.WatchPaths, ","),
WatchPaths: in.WatchPaths,
}
dirty := gtype.NewBool()
_, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gf/internal/cmd/genctrl/genctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type (
SdkStdVersion bool `short:"v" name:"sdkStdVersion" brief:"{CGenCtrlBriefSdkStdVersion}" orphan:"true"`
SdkNoV1 bool `short:"n" name:"sdkNoV1" brief:"{CGenCtrlBriefSdkNoV1}" orphan:"true"`
Clear bool `short:"c" name:"clear" brief:"{CGenCtrlBriefClear}" orphan:"true"`
Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"`
Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"`
}
CGenCtrlOutput struct{}
)
Expand Down
6 changes: 5 additions & 1 deletion cmd/gf/internal/utility/mlog/mlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ var (
)

func init() {
logger.SetStack(false)
if genv.Get(headerPrintEnvName).String() == "1" {
logger.SetHeaderPrint(true)
} else {
logger.SetHeaderPrint(false)
}

if gcmd.GetOpt("debug") != nil || gcmd.GetOpt("gf.debug") != nil {
logger.SetHeaderPrint(true)
logger.SetStackSkip(4)
logger.SetFlags(logger.GetFlags() | glog.F_FILE_LONG)
logger.SetDebug(true)
} else {
logger.SetStack(false)
logger.SetDebug(false)
}
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/config/apollo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/apolloconfig/agollo/v4 v4.3.1
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
)

require (
Expand Down
2 changes: 1 addition & 1 deletion contrib/config/consul/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2
go 1.19

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/hashicorp/consul/api v1.24.0
github.com/hashicorp/go-cleanhttp v0.5.2
)
Expand Down
2 changes: 1 addition & 1 deletion contrib/config/kubecm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2
go 1.19

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
k8s.io/api v0.27.4
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.27.4
Expand Down
2 changes: 1 addition & 1 deletion contrib/config/nacos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/nacos-group/nacos-sdk-go v1.1.4
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/config/polaris/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/polarismesh/polaris-go v1.5.5
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/clickhouse/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/ClickHouse/clickhouse-go/v2 v2.0.15
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/google/uuid v1.3.0
github.com/shopspring/decimal v1.3.1
)
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/dm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../

require (
gitee.com/chunanyong/dm v1.8.12
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
)

require (
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/mssql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/denisenkom/go-mssqldb v0.12.3
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
)

require (
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/mysql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/go-sql-driver/mysql v1.7.1
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
)

require (
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/oracle/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/sijms/go-ora/v2 v2.7.10
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/pgsql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/lib/pq v1.10.9
)

Expand Down
27 changes: 26 additions & 1 deletion contrib/drivers/pgsql/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"context"
"database/sql"
"fmt"
"regexp"
"strings"

_ "github.com/lib/pq"
Expand Down Expand Up @@ -237,6 +238,12 @@ func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string,
if err != nil {
return nil, err
}

useRelpartbound := ""
if gstr.CompareVersion(d.version(ctx, link), "10") >= 0 {
useRelpartbound = "AND c.relpartbound IS NULL"
}

var query = fmt.Sprintf(`
SELECT
c.relname
Expand All @@ -247,10 +254,11 @@ INNER JOIN pg_namespace n ON
WHERE
n.nspname = '%s'
AND c.relkind IN ('r', 'p')
AND c.relpartbound IS NULL
%s
ORDER BY
c.relname`,
usedSchema,
useRelpartbound,
)

query, _ = gregex.ReplaceString(`[\n\r\s]+`, " ", gstr.Trim(query))
Expand All @@ -266,6 +274,23 @@ ORDER BY
return
}

// version checks and returns the database version.
func (d *Driver) version(ctx context.Context, link gdb.Link) string {
result, err := d.DoSelect(ctx, link, "SELECT version();")
if err != nil {
return ""
}
if len(result) > 0 {
if v, ok := result[0]["version"]; ok {
matches := regexp.MustCompile(`PostgreSQL (\d+\.\d+)`).FindStringSubmatch(v.String())
if len(matches) >= 2 {
return matches[1]
}
}
}
return ""
}

// TableFields retrieves and returns the fields' information of specified table of current schema.
func (d *Driver) TableFields(ctx context.Context, table string, schema ...string) (fields map[string]*gdb.TableField, err error) {
var (
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/sqlite/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/glebarez/go-sqlite v1.21.2
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
)

require (
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/sqlitecgo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/mattn/go-sqlite3 v1.14.17
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/nosql/redis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/redis/go-redis/v9 v9.2.1
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/etcd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
go.etcd.io/etcd/client/v3 v3.5.7
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/file/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2

go 1.18

require github.com/gogf/gf/v2 v2.5.7
require github.com/gogf/gf/v2 v2.6.0-beta

require (
github.com/BurntSushi/toml v1.2.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/nacos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/joy999/nacos-sdk-go v0.0.0-20231120071639-10a34b3e7288
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/polaris/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2
go 1.18

require (
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
github.com/polarismesh/polaris-go v1.5.5
)

Expand Down
2 changes: 1 addition & 1 deletion contrib/registry/zookeeper/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/go-zookeeper/zk v1.0.3
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/v2 v2.6.0-beta
golang.org/x/sync v0.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions contrib/rpc/grpcx/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2
go 1.18

require (
github.com/gogf/gf/contrib/registry/file/v2 v2.5.7
github.com/gogf/gf/v2 v2.5.7
github.com/gogf/gf/contrib/registry/file/v2 v2.6.0-beta
github.com/gogf/gf/v2 v2.6.0-beta
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
google.golang.org/grpc v1.57.2
Expand Down
Loading

0 comments on commit 432ab95

Please sign in to comment.