You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed when working on a project that I wasn't getting any results from Cassandra, even though there were results in the database. My code looks like something like this:
qs := "SELECT a, b, c FROM my_table"
query := cqlr.BindQuery(s.Session.Query(qs))
var object MyObject
objects := make([]MyObject, 0)
for query.Scan(&object) {
objects = append(objects, object)
}
if err := query.Close(); err != nil {
return objects, err
}
return objects, nil
Given that MyObject is special in how it is marshalled / unmarshalled, I suspected that there was some error in how I conduct that, but the above code throws no errors.
As it turns out, cqlr masks the error. On cqlr.go#L74, an error is only returned if cqlr had a problem. If there is a problem unmarshalling (as might happen in cqlr.go#L107, the error won't be caught until iter is closed... which doesn't happen.
I think that all that is needed is that in Binding.Close, it returns b.err or b.iter.Close().
The text was updated successfully, but these errors were encountered:
I noticed when working on a project that I wasn't getting any results from Cassandra, even though there were results in the database. My code looks like something like this:
Given that
MyObject
is special in how it is marshalled / unmarshalled, I suspected that there was some error in how I conduct that, but the above code throws no errors.As it turns out,
cqlr
masks the error. On cqlr.go#L74, an error is only returned ifcqlr
had a problem. If there is a problem unmarshalling (as might happen in cqlr.go#L107, the error won't be caught untiliter
is closed... which doesn't happen.I think that all that is needed is that in
Binding.Close
, it returnsb.err
orb.iter.Close()
.The text was updated successfully, but these errors were encountered: