Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed couchdb.toQuery

All values need to be JSON encoded, except stale=ok
  • Loading branch information...
commit f02ba6fe74fd287f07e22d9e720874c634677905 1 parent cb4d08b
Felix Geisendörfer authored
6  lib/couchdb.js
@@ -19,11 +19,11 @@ exports.toJSON = function(data) {
19 19
   });
20 20
 };
21 21
 
22  
-// Use boolean strings since couch expects those
  22
+// Encode query values to JSON except the stale parameter
23 23
 exports.toQuery = function(query) {
24 24
   for (var k in query) {
25  
-    if (typeof query[k] == 'boolean') {
26  
-      query[k] = String(query[k]);
  25
+    if (k !== 'stale') {
  26
+      query[k] = JSON.stringify(query[k]);
27 27
     }
28 28
   }
29 29
   return querystring.stringify(query);
8  test/test-to-query.js
... ...
@@ -0,0 +1,8 @@
  1
+require('./common');
  2
+
  3
+var query = couchdb.toQuery({
  4
+  foo: 'bar',
  5
+  very: true,
  6
+  stale: 'ok'
  7
+});
  8
+assert.equal('foo=%22bar%22&very=true&stale=ok', query);

0 notes on commit f02ba6f

Please sign in to comment.
Something went wrong with that request. Please try again.