Skip to content

Commit

Permalink
Make the code tidy and fixed typo (#84)
Browse files Browse the repository at this point in the history
* fix typo
builder/README.md:289:53: "recieved" is a misspelling of "received"
manager/README.md:59:4: "recieves" is a misspelling of "receives"

* better code
  • Loading branch information
xiekeyi98 authored Jun 20, 2020
1 parent 8d6f9ca commit aa576ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ sign: `BuildDelete(table string, where map[string]interface{}) (string, []interf
If you use `Prepare && stmt.SomeMethods` then You have no need to worry about the safety.
Prepare is a safety mechanism backed by `mysql`, it makes sql injection out of work.

So `builder` **doesn't** escape the string values it recieved -- it's unnecessary
So `builder` **doesn't** escape the string values it received -- it's unnecessary

If you call `db.Query(cond, vals...)` directly, and you **don't** set `interpolateParams` which is one of the driver's variables to `true`, the driver actually will still prepare a stmt.So it's safe.

Expand Down
2 changes: 1 addition & 1 deletion builder/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (bt Between) Build() ([]string, []interface{}) {
}

func betweenBuilder(bt map[string][]interface{}, notBetween bool) ([]string, []interface{}) {
if bt == nil || len(bt) == 0 {
if len(bt) == 0 {
return nil, nil
}
var cond []string
Expand Down
2 changes: 1 addition & 1 deletion manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Port sets the server port,default 3306

`func (o *Option) Set(sets ...Setting) *Option`

Set recieves a series of Set*-like functions
Set receives a series of Set*-like functions

---

Expand Down
18 changes: 12 additions & 6 deletions scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,12 @@ func Test_Scan_Pointer(t *testing.T) {
mp := map[string]interface{}{
"age": tc.in,
}
bind(mp, &u)
err := bind(mp, &u)
if err == nil {
ass.NoError(err)
} else {
ass.Error(err)
}
ass.Equal(tc.out, *u.Age, "case #%d fail", idx)
}
}
Expand All @@ -428,10 +433,6 @@ func float64Ptr(v float64) *float64 {
return &v
}

func int64Ptr(v int64) *int64 {
return &v
}

func stringPtr(s string) *string {
return &s
}
Expand Down Expand Up @@ -490,7 +491,12 @@ func Test_Scan_Multi_Pointer(t *testing.T) {
ass := assert.New(t)
for idx, tc := range testData {
var u user
bind(tc.in, &u)
err := bind(tc.in, &u)
if err == nil {
ass.NoError(err)
} else {
ass.Error(err)
}
ass.Equal(tc.out, u, "case #%d fail %+v", idx, u)
}
}
Expand Down

0 comments on commit aa576ce

Please sign in to comment.