diff --git a/Gopkg.lock b/Gopkg.lock index e4e63a46..ea21e6d9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -115,14 +115,14 @@ [[projects]] branch = "master" - digest = "1:7654989089e5bd5b6734ec3be8b695e87d3f1f8d95620b343fd7d3995a5b60d7" + digest = "1:6c41d4f998a03b6604227ccad36edaed6126c397e5d78709ef4814a1145a6757" name = "github.com/jmoiron/sqlx" packages = [ ".", "reflectx", ] pruneopts = "UT" - revision = "0dae4fefe7c0e190f7b5a78dac28a1c82cc8d849" + revision = "d161d7a76b5661016ad0b085869f77fd410f3e6a" [[projects]] digest = "1:8ef506fc2bb9ced9b151dafa592d4046063d744c646c1bbe801982ce87e4bc24" diff --git a/vendor/github.com/jmoiron/sqlx/README.md b/vendor/github.com/jmoiron/sqlx/README.md index c0db7f78..83903436 100644 --- a/vendor/github.com/jmoiron/sqlx/README.md +++ b/vendor/github.com/jmoiron/sqlx/README.md @@ -20,6 +20,8 @@ explains how to use `database/sql` along with sqlx. ## Recent Changes +* The [introduction](https://github.com/jmoiron/sqlx/pull/387) of `sql.ColumnType` sets the required minimum Go version to 1.8. + * sqlx/types.JsonText has been renamed to JSONText to follow Go naming conventions. This breaks backwards compatibility, but it's in a way that is trivially fixable diff --git a/vendor/github.com/jmoiron/sqlx/bind.go b/vendor/github.com/jmoiron/sqlx/bind.go index 0fdc4435..0a48252a 100644 --- a/vendor/github.com/jmoiron/sqlx/bind.go +++ b/vendor/github.com/jmoiron/sqlx/bind.go @@ -2,6 +2,7 @@ package sqlx import ( "bytes" + "database/sql/driver" "errors" "reflect" "strconv" @@ -16,6 +17,7 @@ const ( QUESTION DOLLAR NAMED + AT ) // BindType returns the bindtype for a given database given a drivername. @@ -29,6 +31,8 @@ func BindType(driverName string) int { return QUESTION case "oci8", "ora", "goracle": return NAMED + case "sqlserver": + return AT } return UNKNOWN } @@ -56,6 +60,8 @@ func Rebind(bindType int, query string) string { rqb = append(rqb, '$') case NAMED: rqb = append(rqb, ':', 'a', 'r', 'g') + case AT: + rqb = append(rqb, '@', 'p') } j++ @@ -110,6 +116,9 @@ func In(query string, args ...interface{}) (string, []interface{}, error) { meta := make([]argMeta, len(args)) for i, arg := range args { + if a, ok := arg.(driver.Valuer); ok { + arg, _ = a.Value() + } v := reflect.ValueOf(arg) t := reflectx.Deref(v.Type()) @@ -137,7 +146,7 @@ func In(query string, args ...interface{}) (string, []interface{}, error) { } newArgs := make([]interface{}, 0, flatArgsCount) - buf := bytes.NewBuffer(make([]byte, 0, len(query)+len(", ?")*flatArgsCount)) + buf := make([]byte, 0, len(query)+len(", ?")*flatArgsCount) var arg, offset int @@ -163,10 +172,10 @@ func In(query string, args ...interface{}) (string, []interface{}, error) { } // write everything up to and including our ? character - buf.WriteString(query[:offset+i+1]) + buf = append(buf, query[:offset+i+1]...) for si := 1; si < argMeta.length; si++ { - buf.WriteString(", ?") + buf = append(buf, ", ?"...) } newArgs = appendReflectSlice(newArgs, argMeta.v, argMeta.length) @@ -177,13 +186,13 @@ func In(query string, args ...interface{}) (string, []interface{}, error) { offset = 0 } - buf.WriteString(query) + buf = append(buf, query...) if arg < len(meta) { return "", nil, errors.New("number of bindVars less than number arguments") } - return buf.String(), newArgs, nil + return string(buf), newArgs, nil } func appendReflectSlice(args []interface{}, v reflect.Value, vlen int) []interface{} { diff --git a/vendor/github.com/jmoiron/sqlx/go.mod b/vendor/github.com/jmoiron/sqlx/go.mod new file mode 100644 index 00000000..66c67561 --- /dev/null +++ b/vendor/github.com/jmoiron/sqlx/go.mod @@ -0,0 +1,7 @@ +module github.com/jmoiron/sqlx + +require ( + github.com/go-sql-driver/mysql v1.4.0 + github.com/lib/pq v1.0.0 + github.com/mattn/go-sqlite3 v1.9.0 +) diff --git a/vendor/github.com/jmoiron/sqlx/go.sum b/vendor/github.com/jmoiron/sqlx/go.sum new file mode 100644 index 00000000..a3239ada --- /dev/null +++ b/vendor/github.com/jmoiron/sqlx/go.sum @@ -0,0 +1,6 @@ +github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4= +github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= diff --git a/vendor/github.com/jmoiron/sqlx/named.go b/vendor/github.com/jmoiron/sqlx/named.go index 69eb9549..fa82b560 100644 --- a/vendor/github.com/jmoiron/sqlx/named.go +++ b/vendor/github.com/jmoiron/sqlx/named.go @@ -259,6 +259,10 @@ func compileNamedQuery(qs []byte, bindType int) (query string, names []string, e } inName = true name = []byte{} + } else if inName && i > 0 && b == '=' { + rebound = append(rebound, ':', '=') + inName = false + continue // if we're in a name, and this is an allowed character, continue } else if inName && (unicode.IsOneOf(allowedBindRunes, rune(b)) || b == '_' || b == '.') && i != last { // append the byte to the name if we are in a name and not on the last byte @@ -287,6 +291,12 @@ func compileNamedQuery(qs []byte, bindType int) (query string, names []string, e rebound = append(rebound, byte(b)) } currentVar++ + case AT: + rebound = append(rebound, '@', 'p') + for _, b := range strconv.Itoa(currentVar) { + rebound = append(rebound, byte(b)) + } + currentVar++ } // add this byte to string unless it was not part of the name if i != last { diff --git a/vendor/github.com/jmoiron/sqlx/sqlx.go b/vendor/github.com/jmoiron/sqlx/sqlx.go index 4385c3fa..3f000f47 100644 --- a/vendor/github.com/jmoiron/sqlx/sqlx.go +++ b/vendor/github.com/jmoiron/sqlx/sqlx.go @@ -471,8 +471,6 @@ func (tx *Tx) Stmtx(stmt interface{}) *Stmt { s = v.Stmt case *Stmt: s = v.Stmt - case sql.Stmt: - s = &v case *sql.Stmt: s = v default: diff --git a/vendor/github.com/jmoiron/sqlx/sqlx_context.go b/vendor/github.com/jmoiron/sqlx/sqlx_context.go index d58ff337..06033111 100644 --- a/vendor/github.com/jmoiron/sqlx/sqlx_context.go +++ b/vendor/github.com/jmoiron/sqlx/sqlx_context.go @@ -217,8 +217,6 @@ func (tx *Tx) StmtxContext(ctx context.Context, stmt interface{}) *Stmt { s = v.Stmt case *Stmt: s = v.Stmt - case sql.Stmt: - s = &v case *sql.Stmt: s = v default: