Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Use strings.Builder instead of builder.StringBuilder (#1417)
Browse files Browse the repository at this point in the history
* use strings.Builder instead of builder.StringBuilder

* fix dependency

* fix dependency
  • Loading branch information
lunny authored Sep 6, 2019
1 parent 61f1d19 commit 57a7e44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ func (engine *Engine) Quote(value string) string {
return value
}

buf := builder.StringBuilder{}
buf := strings.Builder{}
engine.QuoteTo(&buf, value)

return buf.String()
}

// QuoteTo quotes string and writes into the buffer
func (engine *Engine) QuoteTo(buf *builder.StringBuilder, value string) {
func (engine *Engine) QuoteTo(buf *strings.Builder, value string) {
if buf == nil {
return
}
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/go-xorm/xorm

go 1.11

require (
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4
Expand All @@ -14,6 +16,6 @@ require (
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
github.com/stretchr/testify v1.3.0
github.com/ziutek/mymysql v1.5.4
xorm.io/builder v0.3.5
xorm.io/builder v0.3.6-0.20190906062455-b937eb46ecfb
xorm.io/core v0.7.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
xorm.io/builder v0.3.5 h1:EilU39fvWDxjb1cDaELpYhsF+zziRBhew8xk4pngO+A=
xorm.io/builder v0.3.5/go.mod h1:ZFbByS/KxZI1FKRjL05PyJ4YrK2bcxlUaAxdum5aTR8=
xorm.io/builder v0.3.6-0.20190906062455-b937eb46ecfb h1:2idZcp79ldX5qLeQ6WKCdS7aEFNOMvQc9wrtt5hSRwM=
xorm.io/builder v0.3.6-0.20190906062455-b937eb46ecfb/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
xorm.io/core v0.7.0 h1:hKxuOKWZNeiFQsSuGet/KV8HZ788hclvAl+7azx3tkM=
xorm.io/core v0.7.0/go.mod h1:TuOJjIVa7e3w/rN8tDcAvuLBMtwzdHPbyOzE6Gk1EUI=
10 changes: 5 additions & 5 deletions statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func (statement *Statement) OrderBy(order string) *Statement {

// Desc generate `ORDER BY xx DESC`
func (statement *Statement) Desc(colNames ...string) *Statement {
var buf builder.StringBuilder
var buf strings.Builder
if len(statement.OrderStr) > 0 {
fmt.Fprint(&buf, statement.OrderStr, ", ")
}
Expand All @@ -707,7 +707,7 @@ func (statement *Statement) Desc(colNames ...string) *Statement {

// Asc provide asc order by query condition, the input parameters are columns.
func (statement *Statement) Asc(colNames ...string) *Statement {
var buf builder.StringBuilder
var buf strings.Builder
if len(statement.OrderStr) > 0 {
fmt.Fprint(&buf, statement.OrderStr, ", ")
}
Expand Down Expand Up @@ -736,7 +736,7 @@ func (statement *Statement) Table(tableNameOrBean interface{}) *Statement {

// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (statement *Statement) Join(joinOP string, tablename interface{}, condition string, args ...interface{}) *Statement {
var buf builder.StringBuilder
var buf strings.Builder
if len(statement.JoinStr) > 0 {
fmt.Fprintf(&buf, "%v %v JOIN ", statement.JoinStr, joinOP)
} else {
Expand Down Expand Up @@ -801,7 +801,7 @@ func (statement *Statement) genColumnStr() string {
return ""
}

var buf builder.StringBuilder
var buf strings.Builder
columns := statement.RefTable.Columns()

for _, col := range columns {
Expand Down Expand Up @@ -1118,7 +1118,7 @@ func (statement *Statement) genSelectSQL(columnStr, condSQL string, needLimit, n
}
}

var buf builder.StringBuilder
var buf strings.Builder
fmt.Fprintf(&buf, "SELECT %v%v%v%v%v", distinct, top, columnStr, fromStr, whereStr)
if len(mssqlCondi) > 0 {
if len(whereStr) > 0 {
Expand Down

0 comments on commit 57a7e44

Please sign in to comment.