Skip to content

Instantly share code, notes, and snippets.

@mandric
Created December 2, 2011 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mandric/1424480 to your computer and use it in GitHub Desktop.
Save mandric/1424480 to your computer and use it in GitHub Desktop.
couchdb regex test
// fails in couchbase single server, you can test in Futon by pasting into Custom Test
couchTests.custom_test = function(debug) {
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();
if (debug) debugger;
var testregexDoc = {
_id: "_design/testregex",
"shows" : {
"exec" : "function(doc) {\
var re = /test/; return re.exec('testing')[0];\
}",
"test" : "function(doc) {\
var re = /test/; return String(re.test('testing'));\
}"
}
};
var save_response = db.save(testregexDoc);
T(save_response.ok);
var xhr = CouchDB.request("GET", "/test_suite_db/_design/testregex/_show/exec");
T(xhr.responseText == "test");
xhr = CouchDB.request("GET", "/test_suite_db/_design/testregex/_show/test");
T(xhr.responseText == "true");
};
@nrw
Copy link

nrw commented Dec 3, 2011

Is the couchdb community discussing this regex issue somewhere? i'd like to follow the progress.

@mandric
Copy link
Author

mandric commented Dec 3, 2011 via email

@mandric
Copy link
Author

mandric commented Dec 6, 2011

Also posted on the issue tracker. http://www.couchbase.org/issues/browse/CB-83

@mandric
Copy link
Author

mandric commented Dec 19, 2011

It appears only regex literals are broken in couchbase, see: https://gist.github.com/1498086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment