ViewQuery with Key returns empty rows

Hey guys,
this is my code:

vq := gocouchbase.NewViewQuery("users", "get_user_by_id").Key(UserID)
rows := Connector.ExecuteViewQuery(vq)
var row ViewRow_cb
if rows.Next(&row) {
	index = uint64(row.Key)
	token = int64(row.Value.(float64))
}

and this is my view:

function (doc) {
  if (doc.type == "user")
  	emit(doc.id, doc.token);
}

when i run it i get 0 rows back from the server but when i run it without the Key i get N rows(where N is the number of user documents in the DB)

I tried to do it with Range and also modified viewquery.go and add vq.options.Set("inclusive_end", "true") like i do in a webrequest, still no results.

Any ideas?
Thanks.

Hey jesuson,

Could you show me the HTTP query you have that does work? I suspect you may be using Key in place of Id or some other issue than a ViewQuery generation issue directly.

Cheers, Brett

Sure,
http://localhost:8092/myapp/_design/users/_view/get_user_by_id
{“total_rows”:5,“rows”:[
{“id”:“user_83”,“key”:83,“value”:1423665082},
{“id”:“user_84”,“key”:84,“value”:1423665781},
{“id”:“user_104”,“key”:104,“value”:1423668662},
{“id”:“user_105”,“key”:105,“value”:1423668676},
{“id”:“user_107”,“key”:107,“value”:1423668750}
]
}

http://localhost:8092/myapp/_design/users/_view/get_user_by_id?key=84
{“total_rows”:5,“rows”:[
{“id”:“user_84”,“key”:84,“value”:1423665781}
]
}

couchbase: 3.0.1
GO SDK: github.com/couchbaselabs/gocouchbase

Hey jesuson,

I think I know what the issue is. You can track it here: http://issues.couchbase.com/browse/GOCBC-15.

Cheers, Brett

amazing! great catch!
any chance this will be fixed in the .Next version?
Thanks.

Hey jesuson,

It certainly will be, and that release is scheduled for the first Tuesday of March, though I am considering doing it a little earlier if we are ahead of schedule :smile:

Cheers, Brett