Skip to content

Instantly share code, notes, and snippets.

--- mongodb.js.orig 2010-04-30 22:19:10.000000000 +0400
+++ mongodb.js 2010-05-01 16:03:49.000000000 +0400
@@ -85,7 +85,6 @@
if(typeof query === "string"){
query = parseQuery(query);
}
- var grabOneColumn, deleteId;
var options = {};
query.forEach(function(term){
function stringToValue(string, parameters){
switch(string){
case "true": return true;
case "false": return false;
case "null": return null;
default:
// DVV: handle arrays
if (string.indexOf(',') > -1) {
var r = [];
string.split(',').forEach(function(x){
--- rest-store.js.orig 2010-05-04 18:59:11.000000000 +0400
+++ rest-store.js 2010-05-04 01:08:07.000000000 +0400
@@ -63,19 +63,19 @@
else if(!METHOD_HAS_BODY[method]){
if(method === "get" && request.pathInfo.substring(request.pathInfo.length - 1) === "/"){
// handle the range header
- if(metadata.range){
- // invalid "Range:" just results in 0-Infinity
+ if (metadata.range) {
+ // invalid "Range:" are ignored
--- resource-query.js.orig 2010-05-03 20:15:43.000000000 +0400
+++ resource-query.js 2010-05-03 23:34:14.000000000 +0400
@@ -13,7 +13,8 @@
}
var terms = [];
var originalTerms = terms;
- if(query.replace(/([&\|,])?(([\+\*\-:\w%\._]+)(=[a-z]*=|=|=?<|=?>|!=)([\+\*\$\-:\w%\._]+)|(([\+\*\\$\-:\w%\._]+)(\(?))|(\))|(.+))/g,
+// if(query.replace(/([&\|,])?(([\+\*\-:\w%\._]+)(=[a-z]*=|=|=?<|=?>|!=)([\+\*\$\-:\w%\._]+)|(([\+\*\\$\-:\w%\._]+)(\(?))|(\))|(.+))/g,
+ if(query.replace(/([&\|,])?(([\+\*\-:\w%\._]+)(=[a-z]*=|=|=?<|=?>|!=)([\+\*\$\-:\w%\._,]+)|(([\+\*\\$\-:\w%\._]+)(\(?))|(\))|(.+))/g,
// <-delim-> <--- name --------- comparator ----- value ---->|<-function/value -- openParan->|<-closedParan->|<-illegalCharacter->
--- mongodb.js.orig 2010-05-04 18:59:13.000000000 +0400
+++ mongodb.js 2010-05-04 19:23:16.000000000 +0400
@@ -110,19 +110,23 @@
} else if (term.name == "select") {
options.fields = term.parameters;
} else if (term.name == "slice") {
- directives.start = term.parameters[0];
- directives.end = term.parameters[1];
+ // DVV: .start/.end MUST be numbers, or .start + a-number will result in string concat
+ // DVV: better to get rid of slice() at all, as it _may_ introduce inconsistency with range set via Range: header. As deanlandolt stated, .slice() is to mimic JS intrinsic Array.slice() and should be chainable. IOW, it doesn't fit to control server-side conditions
exports.convertors = {
"number" : function(x){
var n = +x;
return (!isNaN(n)) ? n : x;
},
"date" : function(x){
var date = x + "0000-01-01T00:00:00Z".substring(x.length);
date.replace(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/, function(dummy, y, mp1, d, h, m, s){
x = new Date(Date.UTC(+y, +mp1 - 1, +d, +h, +m, +s));
});
--- node-http-client.js.orig 2010-05-06 09:00:57.542606864 +0400
+++ node-http-client.js 2010-05-06 09:09:51.000000000 +0400
@@ -22,12 +22,12 @@
request.pathname = request.url;
var proxySettings = parse(exports.proxyServer);
request.port = proxySettings.port;
- request.host = proxySettings.host;
+ request.host = proxySettings.hostname;
}
var exports = {};
exports.jsonQueryCompatible = true;
var operatorMap = {
"=": "eq",
"==": "eq",
">": "gt",
">=": "ge",
"<": "lt",
"<=": "le",
"!=": "ne"
?date=date:2010
---------------
[ { name: 'eq'
, args: [ 'date', Thu, 01 Jan 1970 00:00:02 GMT ]
}
]
?date=date:2010-05
---------------
diff --git a/lib/mongodb/bson/bson.js b/lib/mongodb/bson/bson.js
index 4194f5e..bf9094a 100644
--- a/lib/mongodb/bson/bson.js
+++ b/lib/mongodb/bson/bson.js
@@ -214,7 +214,7 @@ BSON.deserialize = function(data, is_array_item, returnData, returnArray) {
// Read the oid (12 bytes)
var oid = data.substr(index, 12);
// Calculate date with miliseconds
- var value = new exports.ObjectID(oid);
+ var value = ObjectID.createPk(oid);