mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
Update SQLX dependency
This commit is contained in:
parent
516140dd7e
commit
b3383f46ca
8 changed files with 41 additions and 11 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -115,14 +115,14 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:7654989089e5bd5b6734ec3be8b695e87d3f1f8d95620b343fd7d3995a5b60d7"
|
digest = "1:6c41d4f998a03b6604227ccad36edaed6126c397e5d78709ef4814a1145a6757"
|
||||||
name = "github.com/jmoiron/sqlx"
|
name = "github.com/jmoiron/sqlx"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
"reflectx",
|
"reflectx",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "0dae4fefe7c0e190f7b5a78dac28a1c82cc8d849"
|
revision = "d161d7a76b5661016ad0b085869f77fd410f3e6a"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:8ef506fc2bb9ced9b151dafa592d4046063d744c646c1bbe801982ce87e4bc24"
|
digest = "1:8ef506fc2bb9ced9b151dafa592d4046063d744c646c1bbe801982ce87e4bc24"
|
||||||
|
|
2
vendor/github.com/jmoiron/sqlx/README.md
generated
vendored
2
vendor/github.com/jmoiron/sqlx/README.md
generated
vendored
|
@ -20,6 +20,8 @@ explains how to use `database/sql` along with sqlx.
|
||||||
|
|
||||||
## Recent Changes
|
## 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.
|
* 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
|
This breaks backwards compatibility, but it's in a way that is trivially fixable
|
||||||
|
|
19
vendor/github.com/jmoiron/sqlx/bind.go
generated
vendored
19
vendor/github.com/jmoiron/sqlx/bind.go
generated
vendored
|
@ -2,6 +2,7 @@ package sqlx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"database/sql/driver"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -16,6 +17,7 @@ const (
|
||||||
QUESTION
|
QUESTION
|
||||||
DOLLAR
|
DOLLAR
|
||||||
NAMED
|
NAMED
|
||||||
|
AT
|
||||||
)
|
)
|
||||||
|
|
||||||
// BindType returns the bindtype for a given database given a drivername.
|
// BindType returns the bindtype for a given database given a drivername.
|
||||||
|
@ -29,6 +31,8 @@ func BindType(driverName string) int {
|
||||||
return QUESTION
|
return QUESTION
|
||||||
case "oci8", "ora", "goracle":
|
case "oci8", "ora", "goracle":
|
||||||
return NAMED
|
return NAMED
|
||||||
|
case "sqlserver":
|
||||||
|
return AT
|
||||||
}
|
}
|
||||||
return UNKNOWN
|
return UNKNOWN
|
||||||
}
|
}
|
||||||
|
@ -56,6 +60,8 @@ func Rebind(bindType int, query string) string {
|
||||||
rqb = append(rqb, '$')
|
rqb = append(rqb, '$')
|
||||||
case NAMED:
|
case NAMED:
|
||||||
rqb = append(rqb, ':', 'a', 'r', 'g')
|
rqb = append(rqb, ':', 'a', 'r', 'g')
|
||||||
|
case AT:
|
||||||
|
rqb = append(rqb, '@', 'p')
|
||||||
}
|
}
|
||||||
|
|
||||||
j++
|
j++
|
||||||
|
@ -110,6 +116,9 @@ func In(query string, args ...interface{}) (string, []interface{}, error) {
|
||||||
meta := make([]argMeta, len(args))
|
meta := make([]argMeta, len(args))
|
||||||
|
|
||||||
for i, arg := range args {
|
for i, arg := range args {
|
||||||
|
if a, ok := arg.(driver.Valuer); ok {
|
||||||
|
arg, _ = a.Value()
|
||||||
|
}
|
||||||
v := reflect.ValueOf(arg)
|
v := reflect.ValueOf(arg)
|
||||||
t := reflectx.Deref(v.Type())
|
t := reflectx.Deref(v.Type())
|
||||||
|
|
||||||
|
@ -137,7 +146,7 @@ func In(query string, args ...interface{}) (string, []interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
newArgs := make([]interface{}, 0, flatArgsCount)
|
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
|
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
|
// 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++ {
|
for si := 1; si < argMeta.length; si++ {
|
||||||
buf.WriteString(", ?")
|
buf = append(buf, ", ?"...)
|
||||||
}
|
}
|
||||||
|
|
||||||
newArgs = appendReflectSlice(newArgs, argMeta.v, argMeta.length)
|
newArgs = appendReflectSlice(newArgs, argMeta.v, argMeta.length)
|
||||||
|
@ -177,13 +186,13 @@ func In(query string, args ...interface{}) (string, []interface{}, error) {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString(query)
|
buf = append(buf, query...)
|
||||||
|
|
||||||
if arg < len(meta) {
|
if arg < len(meta) {
|
||||||
return "", nil, errors.New("number of bindVars less than number arguments")
|
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{} {
|
func appendReflectSlice(args []interface{}, v reflect.Value, vlen int) []interface{} {
|
||||||
|
|
7
vendor/github.com/jmoiron/sqlx/go.mod
generated
vendored
Normal file
7
vendor/github.com/jmoiron/sqlx/go.mod
generated
vendored
Normal file
|
@ -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
|
||||||
|
)
|
6
vendor/github.com/jmoiron/sqlx/go.sum
generated
vendored
Normal file
6
vendor/github.com/jmoiron/sqlx/go.sum
generated
vendored
Normal file
|
@ -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=
|
10
vendor/github.com/jmoiron/sqlx/named.go
generated
vendored
10
vendor/github.com/jmoiron/sqlx/named.go
generated
vendored
|
@ -259,6 +259,10 @@ func compileNamedQuery(qs []byte, bindType int) (query string, names []string, e
|
||||||
}
|
}
|
||||||
inName = true
|
inName = true
|
||||||
name = []byte{}
|
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
|
// 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 {
|
} 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
|
// 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))
|
rebound = append(rebound, byte(b))
|
||||||
}
|
}
|
||||||
currentVar++
|
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
|
// add this byte to string unless it was not part of the name
|
||||||
if i != last {
|
if i != last {
|
||||||
|
|
2
vendor/github.com/jmoiron/sqlx/sqlx.go
generated
vendored
2
vendor/github.com/jmoiron/sqlx/sqlx.go
generated
vendored
|
@ -471,8 +471,6 @@ func (tx *Tx) Stmtx(stmt interface{}) *Stmt {
|
||||||
s = v.Stmt
|
s = v.Stmt
|
||||||
case *Stmt:
|
case *Stmt:
|
||||||
s = v.Stmt
|
s = v.Stmt
|
||||||
case sql.Stmt:
|
|
||||||
s = &v
|
|
||||||
case *sql.Stmt:
|
case *sql.Stmt:
|
||||||
s = v
|
s = v
|
||||||
default:
|
default:
|
||||||
|
|
2
vendor/github.com/jmoiron/sqlx/sqlx_context.go
generated
vendored
2
vendor/github.com/jmoiron/sqlx/sqlx_context.go
generated
vendored
|
@ -217,8 +217,6 @@ func (tx *Tx) StmtxContext(ctx context.Context, stmt interface{}) *Stmt {
|
||||||
s = v.Stmt
|
s = v.Stmt
|
||||||
case *Stmt:
|
case *Stmt:
|
||||||
s = v.Stmt
|
s = v.Stmt
|
||||||
case sql.Stmt:
|
|
||||||
s = &v
|
|
||||||
case *sql.Stmt:
|
case *sql.Stmt:
|
||||||
s = v
|
s = v
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue