Details
-
Bug
-
Resolution: User Error
-
Major
-
None
-
None
-
None
-
None
Description
Hi,
I'm having an issue with the developer version found here:
github.com/couchbase/gocb
The issue is with N1QL and reviewing the QueryResults that are returned. Take the following Golang snippet:
```
var n1qlParams []interface{}
n1qlParams = append(n1qlParams, context.Get(req, "pid").(string))
query := gocb.NewN1qlQuery("SELECT `" + bucket.Name() + "`.* FROM `" + bucket.Name() + "` WHERE type = 'blog' AND pid = $1")
rows, err := bucket.ExecuteN1qlQuery(query, n1qlParams)
fmt.Println(query, n1qlParams)
if err != nil {
w.WriteHeader(401)
w.Write([]byte(err.Error()))
return
}
var row Blog
var result []Blog
/*rows.One(&row)
fmt.Println(row)*/
for rows.Next(&row) {
fmt.Println(row)
result = append(result, row)
row = Blog{}
}
```
The first print that spits out the query and the N1QL parameters is accurate. The loop for the results is skipped because .Next is nil. However, if you uncomment the .One, it works fine. It is my understanding that .One calls .Next.
Query monitoring using Couchbase log data determined that Couchbase is in fact receiving the correct query and the query is executing correctly. The problem is how Go is handling the results.
Any more information needed, let me know.
Thanks,