update UseContext example to handle rows.Err() correct#1726
update UseContext example to handle rows.Err() correct#1726kavirajk merged 3 commits intoClickHouse:mainfrom
UseContext example to handle rows.Err() correct#1726Conversation
|
@ehsansouri23 thanks for the PR. I think it's nice to have that error check on that example. But looks like that exposed some problem with |
|
@kavirajk Tests have been fixed |
examples/std/context.go
Outdated
| } | ||
| } | ||
| // query is cancelled using Context, so rows.Err() will return context canceled error | ||
| if err := rows.Err(); err == nil { |
There was a problem hiding this comment.
I don't think this is correct. What's the rationale for ignoring the rows.Err() here?
There was a problem hiding this comment.
if col2 == 3 the context is canceled, after that the rows will return context cancel error.
I didn't ignore the error. I assume that error should not be nil. we should have an error, because context is canceled before.
There was a problem hiding this comment.
True. But we should only ignore the context.Cancelled error not any other errors (that could be legit bug).
I pushed a commit to fix it.
kavirajk
left a comment
There was a problem hiding this comment.
We shouldn't ignore the err
Signed-off-by: Kaviraj <[email protected]>
UseContext example to handle rows.Err() correct
Check rows Error
Check rows.Err() after rows.Next(). related to this PR: #804