iterx: Refactor DefaultUnsafe handling
Assign unsafe from DefaultUnsafe and simplify condition. Signed-off-by: Michał Matczuk <michal@scylladb.com>
This commit is contained in:
committed by
Michal Jan Matczuk
parent
92c739c2db
commit
a9ce16bfc6
3
iterx.go
3
iterx.go
@@ -36,6 +36,7 @@ func Iter(q *gocql.Query) *Iterx {
|
|||||||
return &Iterx{
|
return &Iterx{
|
||||||
Iter: q.Iter(),
|
Iter: q.Iter(),
|
||||||
Mapper: DefaultMapper,
|
Mapper: DefaultMapper,
|
||||||
|
unsafe: DefaultUnsafe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +216,7 @@ func (iter *Iterx) StructScan(dest interface{}) bool {
|
|||||||
|
|
||||||
iter.fields = m.TraversalsByName(v.Type(), columns)
|
iter.fields = m.TraversalsByName(v.Type(), columns)
|
||||||
// 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 && !DefaultUnsafe {
|
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 %q in %T", columns[f], dest)
|
iter.err = fmt.Errorf("missing destination name %q in %T", columns[f], dest)
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user