-
Notifications
You must be signed in to change notification settings - Fork 4
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
start_time and end_time confusion #4
Comments
I don't think this an issue in with couchgo - I think this is an issue with couchdb having a bad api. Golangs net.url requires the Values to be in format map[string][]string In the couchgo Client UrlString correctly calls the following:
So it's impossible to pass a string array as a value and if you try to pass "[val]" it encodes the square brackets. I don't think Go is wrong here - I think the couchdb API is not well formed. Any suggestions of a workaround would be welcome but I guess I can just Get the URL directly without using the client.View function. |
This is an interesting issue! To be honest, I haven't looked at this library in a long time. Any suggestions how it could be made to work without blowing up existing functionality? |
I've found a workaround however it's not pretty and there may be a better method. It also seems I have to bypass couchgo.View. As mentioned previously I don't think this is the fault of couchgo - it seems to be shortsightedness of the couch view API not conforming to JSON standards The following is a struct I've created which allows me to accomplish my goal - frankly I hate the implementation. I check for the members which require [ ] - extract the values from the params map, delete the values from the params map, encode the params map and then concatenate the values onto the encoded string. Feel free to suggest a better method :)
|
I tried using the couchgo View option and either misunderstood it or hit a bug.
I want to use start_time and end_time as outlined on the couchdb api:
https://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
The start and end_times should have format [time]
I create url.Values
params := url.Values{lumencouch.IncludeDocs:[]string{"true"}, lumencouch.StartKey:[]string{startKey)}, lumencouch.EndKey:[]string{endKey)}}
However when I query the params end up being:
It seems that as this was a single value in an array the square braces are removed and the query doesn't work
I tried adding the braces manually
params := url.Values{lumencouch.IncludeDocs:[]string{"true"}, lumencouch.StartKey:[]string{fmt.Sprintf("[%s]",startKey)}, lumencouch.EndKey:[]string{fmt.Sprintf("[%s]",endKey)}}
However, this resulted in the braces being encoded
end_key=%5B1478193145176006200%5D&include_docs=true&start_key=%5B1478193025035134981%5D 200
I'm guessing the keys parameter might be of some assistance here but it's not clear how.
Is this a bug or an I misunderstanding something?
The text was updated successfully, but these errors were encountered: