janmonschke / backbone-couchdb

A couchdb connector for backbone with support for real time changes.

Home Page:http://janmonschke.com/projects/backbone-couchdb.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

?keys=null is appended to GET requests and causes 500 error

ryonlife opened this issue · comments

Thanks for much for the work you've put into this connector.

Whenever I fetch a collection, a ?keys=null query sting is appended to the end of the URL, which results in a 500 error:

{"error":"unknown_error","reason":"function_clause"}

My view's map function looks like this:

map: function(doc) { if (doc.collection == 'memories') { emit('doc', doc); } }

When I comment out line 75, there's no longer a query string and there are no problems fetching the collection.

What am I missing that his basic collection fetch doesn't work? And how is the keys feature intended to be used?

Exact same issue here.
Putting aside the funny error message, which seems to be CouchDB's problem, possibly caused by how I upgraded to 1.1.
My solution is to change backbone-couchdb.js line 72
if ((_ref = coll.db.keys) != null) {keys = _ref;}
// keys = (_ref = coll.db.keys) != null ? _ref : null;

keys = should not appear in the query unless it has a value.

If I knew how, I'd fix the Coffee source.

Looking into it ;)

Is it working for you?

Patch not working.
{"error":"bad_request","reason":"keys member must be a array."}

Same for me. Apologies I haven't had the time to patch myself.

No worries. I think we both know what Jan will do next. It's an empty array required, not an object.
Anyway I am fine for now.

Should be fixed now. Thanks for pointing me to that error!

I just tested the latest patch [with empty array].
I expected that to work, but it does not. There's no error, but rows are not retrieved when they should be.
So far, only my proposed solution is working for me.

Do you have a test case for open query (no key specified) ?

There is a test suite located here:
https://github.com/janmonschke/backbone-couchdb/tree/master/chat_example/_attachments/test
And it includes tests for custom view queries. One of the test was failing but I didn't notice.

I'm pretty sure that all tests were green when I submitted the Coffeescript rewrite. Maybe it has something to do with the version of Couchbase server that I'm using now. Right after the Coffeescript rewrite I switched from CouchDBX to the Couchbase Server.

I just submitted another patch that fixes the problem, hopefully ;) -> 51fc238

Jan,

Thanks for all your efforts. That fixes the problem for me. {"couchdb":"Welcome","version":"1.2.0a-1148215"}.
I am not an expert on CouchDB, but I'd be surprised if there's a discrepancy here between any 1.0+ versions of CouchDB or CouchBase. The Views API http://wiki.apache.org/couchdb/HTTP_view_API does seem to be long-time stable and CouchBase only adds a Geo package afaik.

  • Andrew

There's a console.log left in there, but that did the trick.