Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cqlr masks gocql errors when Scanning #6

Open
nt3rp opened this issue Nov 11, 2014 · 0 comments
Open

cqlr masks gocql errors when Scanning #6

nt3rp opened this issue Nov 11, 2014 · 0 comments

Comments

@nt3rp
Copy link
Contributor

nt3rp commented Nov 11, 2014

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant