Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/gorm.io/driver/mysql…
Browse files Browse the repository at this point in the history
…-1.5.2
  • Loading branch information
tr1v3r authored Dec 21, 2023
2 parents 12d19f1 + 910d3f5 commit 20bed3e
Show file tree
Hide file tree
Showing 7 changed files with 2,701 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ jobs:
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
golangci_lint_flags: '--timeout 5m'
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
run: docker exec mysql_server mysql -uroot -p123456 -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';"

- name: Set up Go 1.x
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand Down
12 changes: 12 additions & 0 deletions do_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ func TestDO_methods(t *testing.T) {
Expr: u.Order(u.ID.Desc()).Order(u.Age),
Result: "ORDER BY `id` DESC,`age`",
},
{
Expr: u.Order(u.ID.Asc()),
Result: "ORDER BY `id` ASC",
},
{
Expr: u.Order(u.ID.Asc(), u.Age),
Result: "ORDER BY `id` ASC,`age`",
},
{
Expr: u.Order(u.ID.Asc()).Order(u.Age),
Result: "ORDER BY `id` ASC,`age`",
},
{
Expr: u.Clauses(hints.New("hint")).Select(),
Result: "SELECT /*+ hint */ *",
Expand Down
4 changes: 4 additions & 0 deletions field/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func TestExpr_Build(t *testing.T) {
Expr: field.NewAsterisk("user").Count(),
Result: "COUNT(`user`.*)",
},
{
Expr: field.ALL.Count().As("num"),
Result: "COUNT(*) AS `num`",
},
{
Expr: field.NewAsterisk("user").Distinct().Count(),
Result: "COUNT(DISTINCT `user`.*)",
Expand Down
7 changes: 7 additions & 0 deletions field/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Expr interface {
type OrderExpr interface {
Expr
Desc() Expr
Asc() Expr
}

type expression interface{}
Expand Down Expand Up @@ -274,10 +275,16 @@ func (e expr) As(alias string) Expr {
return e
}

// Desc sort by desc
func (e expr) Desc() Expr {
return e.setE(clause.Expr{SQL: "? DESC", Vars: []interface{}{e.RawExpr()}})
}

// Asc sort by asc
func (e expr) Asc() Expr {
return e.setE(clause.Expr{SQL: "? ASC", Vars: []interface{}{e.RawExpr()}})
}

// ======================== general experssion ========================
func (e expr) value(value interface{}) AssignExpr {
return e.setE(clause.Eq{Column: e.col.Name, Value: value})
Expand Down
35 changes: 17 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ module gorm.io/gen
go 1.18

require (
golang.org/x/tools v0.6.0
golang.org/x/tools v0.15.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c
gorm.io/driver/clickhouse v0.5.0
gorm.io/driver/clickhouse v0.6.0
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.4.5
gorm.io/driver/sqlite v1.4.3
gorm.io/driver/sqlserver v1.4.1
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55
gorm.io/gorm v1.25.2
gorm.io/hints v1.1.0
gorm.io/plugin/dbresolver v1.3.0
gorm.io/plugin/dbresolver v1.5.0
)

require (
github.com/ClickHouse/ch-go v0.48.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.3.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/ClickHouse/ch-go v0.58.2 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.15.0 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.6.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
Expand All @@ -37,19 +37,18 @@ require (
github.com/jackc/pgx/v4 v4.17.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/microsoft/go-mssqldb v0.17.0 // indirect
github.com/paulmach/orb v0.7.1 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/paulmach/orb v0.10.0 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/stretchr/testify v1.8.2 // indirect
go.opentelemetry.io/otel v1.10.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.8.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
)
Loading

0 comments on commit 20bed3e

Please sign in to comment.