error: %s replaced with %q in missing field errors

This commit is contained in:
Michał Matczuk
2017-09-21 21:14:28 +02:00
parent faa3a42062
commit 46603152a1
3 changed files with 5 additions and 5 deletions

View File

@@ -231,7 +231,7 @@ func TestUnsafe(t *testing.T) {
t.Run("safe get", func(t *testing.T) { t.Run("safe get", func(t *testing.T) {
var v UnsafeTable var v UnsafeTable
i := gocqlx.Iter(session.Query(`SELECT * FROM unsafe_table`)) i := gocqlx.Iter(session.Query(`SELECT * FROM unsafe_table`))
if err := i.Get(&v); err == nil || err.Error() != "missing destination name testtextunbound in *gocqlx_test.UnsafeTable" { if err := i.Get(&v); err == nil || err.Error() != "missing destination name \"testtextunbound\" in *gocqlx_test.UnsafeTable" {
t.Fatal("expected ErrNotFound", "got", err) t.Fatal("expected ErrNotFound", "got", err)
} }
}) })
@@ -239,7 +239,7 @@ func TestUnsafe(t *testing.T) {
t.Run("safe select", func(t *testing.T) { t.Run("safe select", func(t *testing.T) {
var v []UnsafeTable var v []UnsafeTable
i := gocqlx.Iter(session.Query(`SELECT * FROM unsafe_table`)) i := gocqlx.Iter(session.Query(`SELECT * FROM unsafe_table`))
if err := i.Select(&v); err == nil || err.Error() != "missing destination name testtextunbound in *gocqlx_test.UnsafeTable" { if err := i.Select(&v); err == nil || err.Error() != "missing destination name \"testtextunbound\" in *gocqlx_test.UnsafeTable" {
t.Fatal("expected ErrNotFound", "got", err) t.Fatal("expected ErrNotFound", "got", err)
} }
if cap(v) > 0 { if cap(v) > 0 {

View File

@@ -228,7 +228,7 @@ func (iter *Iterx) StructScan(dest interface{}) bool {
// if we are not unsafe and are missing fields, return an error // if we are not unsafe and are missing fields, return an error
if !iter.unsafe { if !iter.unsafe {
if f, err := missingFields(iter.fields); err != nil { if f, err := missingFields(iter.fields); err != nil {
iter.err = fmt.Errorf("missing destination name %s in %T", columns[f], dest) iter.err = fmt.Errorf("missing destination name %q in %T", columns[f], dest)
return false return false
} }
} }

View File

@@ -138,7 +138,7 @@ func bindStructArgs(names []string, arg0 interface{}, arg1 map[string]interface{
} else { } else {
val, ok := arg1[names[i]] val, ok := arg1[names[i]]
if !ok { if !ok {
return arglist, fmt.Errorf("could not find name %s in %#v and %#v", names[i], arg0, arg1) return arglist, fmt.Errorf("could not find name %q in %#v and %#v", names[i], arg0, arg1)
} }
arglist = append(arglist, val) arglist = append(arglist, val)
} }
@@ -166,7 +166,7 @@ func bindMapArgs(names []string, arg map[string]interface{}) ([]interface{}, err
for _, name := range names { for _, name := range names {
val, ok := arg[name] val, ok := arg[name]
if !ok { if !ok {
return arglist, fmt.Errorf("could not find name %s in %#v", name, arg) return arglist, fmt.Errorf("could not find name %q in %#v", name, arg)
} }
arglist = append(arglist, val) arglist = append(arglist, val)
} }