|
@@ -117,13 +117,14 @@ proto._parse = function _parse(obj, topLevel){
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
return {'code':'FAILED_TO_PARSE', 'desc':'Where unimplimented.'};
|
|
return {'code':'FAILED_TO_PARSE', 'desc':'Where unimplimented.'};
|
|
|
-
|
|
|
|
|
|
|
+ /*
|
|
|
status = this.expressionParserWhereCallback(element);
|
|
status = this.expressionParserWhereCallback(element);
|
|
|
if (status.code != ErrorCodes.OK)
|
|
if (status.code != ErrorCodes.OK)
|
|
|
return status;
|
|
return status;
|
|
|
- root.add(status.result);
|
|
|
|
|
|
|
+ root.add(status.result);*/
|
|
|
}
|
|
}
|
|
|
else if ("comment" == rest) {
|
|
else if ("comment" == rest) {
|
|
|
|
|
+ 1+1;
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
return {code:ErrorCodes.BAD_VALUE, description:"unknown top level operator: " + currname};
|
|
return {code:ErrorCodes.BAD_VALUE, description:"unknown top level operator: " + currname};
|
|
@@ -198,7 +199,7 @@ proto._parseAll = function _parseAll(name, element){
|
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$all/$elemMatch has to be consistent"};
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$all/$elemMatch has to be consistent"};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- status = this._parseElemMatch("", hopefullyElemMatchElement['$elemMatch'] ); // TODO: wrong way to do this?
|
|
|
|
|
|
|
+ status = this._parseElemMatch("", hopefullyElemMatchElement.$elemMatch ); // TODO: wrong way to do this?
|
|
|
if (status.code != ErrorCodes.OK)
|
|
if (status.code != ErrorCodes.OK)
|
|
|
return status;
|
|
return status;
|
|
|
temp.add(status.result);
|
|
temp.add(status.result);
|
|
@@ -353,12 +354,12 @@ proto._parseMOD = function _parseMOD(name, element){
|
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, not enough elements"};
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, not enough elements"};
|
|
|
if (element.length > 2)
|
|
if (element.length > 2)
|
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, too many elements"};
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, too many elements"};
|
|
|
- if (!(element[0] instanceof Number || typeof(element[0]) == 'number')) {
|
|
|
|
|
|
|
+ if ((typeof(element[0]) != 'number')) {
|
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, divisor not a number"};
|
|
return {code:ErrorCodes.BAD_VALUE, result:"malformed mod, divisor not a number"};
|
|
|
} else {
|
|
} else {
|
|
|
d = element[0];
|
|
d = element[0];
|
|
|
}
|
|
}
|
|
|
- if (!(element[1] instanceof Number || typeof(element[1]) == 'number')) {
|
|
|
|
|
|
|
+ if (( typeof(element[1]) != 'number') ) {
|
|
|
r = 0;
|
|
r = 0;
|
|
|
} else {
|
|
} else {
|
|
|
r = element[1];
|
|
r = element[1];
|
|
@@ -430,8 +431,8 @@ proto._parseRegexDocument = function _parseRegexDocument(name, doc){
|
|
|
// File: expression_parser.cpp lines: 402-442
|
|
// File: expression_parser.cpp lines: 402-442
|
|
|
var regex = '', regexOptions = '', e;
|
|
var regex = '', regexOptions = '', e;
|
|
|
|
|
|
|
|
- if(doc['$regex']) {
|
|
|
|
|
- e = doc['$regex'];
|
|
|
|
|
|
|
+ if(doc.$regex) {
|
|
|
|
|
+ e = doc.$regex;
|
|
|
if(e instanceof RegExp) {
|
|
if(e instanceof RegExp) {
|
|
|
var str = e.toString(),
|
|
var str = e.toString(),
|
|
|
flagIndex = 0;
|
|
flagIndex = 0;
|
|
@@ -443,15 +444,15 @@ proto._parseRegexDocument = function _parseRegexDocument(name, doc){
|
|
|
}
|
|
}
|
|
|
regex = (flagIndex? str : str.substr(1, flagIndex-1));
|
|
regex = (flagIndex? str : str.substr(1, flagIndex-1));
|
|
|
regexOptions = str.substr(flagIndex, str.length);
|
|
regexOptions = str.substr(flagIndex, str.length);
|
|
|
- } else if (typeof(e) == 'string' || e instanceof String) {
|
|
|
|
|
|
|
+ } else if (typeof(e) == 'string') {
|
|
|
regex = e;
|
|
regex = e;
|
|
|
} else {
|
|
} else {
|
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$regex has to be a string"};
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$regex has to be a string"};
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(doc['$options']) {
|
|
|
|
|
- e = doc['$options'];
|
|
|
|
|
|
|
+ if(doc.$options) {
|
|
|
|
|
+ e = doc.$options;
|
|
|
if(typeof(e) == 'string') {
|
|
if(typeof(e) == 'string') {
|
|
|
regexOptions = e;
|
|
regexOptions = e;
|
|
|
} else {
|
|
} else {
|
|
@@ -601,10 +602,10 @@ proto._parseSubField = function _parseSubField(context, andSoFar, name, element)
|
|
|
|
|
|
|
|
case '$size':
|
|
case '$size':
|
|
|
var size = 0;
|
|
var size = 0;
|
|
|
- if (currval instanceof String || typeof(currval) === 'string')
|
|
|
|
|
|
|
+ if ( typeof(currval) === 'string')
|
|
|
// matching old odd semantics
|
|
// matching old odd semantics
|
|
|
size = 0;
|
|
size = 0;
|
|
|
- else if (typeof(currval) === 'number' || currval instanceof Number)
|
|
|
|
|
|
|
+ else if (typeof(currval) === 'number')
|
|
|
size = currval;
|
|
size = currval;
|
|
|
else {
|
|
else {
|
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$size needs a number"};
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$size needs a number"};
|
|
@@ -633,7 +634,7 @@ proto._parseSubField = function _parseSubField(context, andSoFar, name, element)
|
|
|
return {code:ErrorCodes.OK, result:temp2};
|
|
return {code:ErrorCodes.OK, result:temp2};
|
|
|
|
|
|
|
|
case '$type':
|
|
case '$type':
|
|
|
- if (!(currval instanceof Number || typeof(currval) === 'number'))
|
|
|
|
|
|
|
+ if (typeof(currval) != 'number')
|
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$type has to be a number"};
|
|
return {code:ErrorCodes.BAD_VALUE, description:"$type has to be a number"};
|
|
|
var type = currval;
|
|
var type = currval;
|
|
|
temp = new TypeMatchExpression();
|
|
temp = new TypeMatchExpression();
|
|
@@ -670,8 +671,10 @@ proto._parseSubField = function _parseSubField(context, andSoFar, name, element)
|
|
|
case '$geoIntersects':
|
|
case '$geoIntersects':
|
|
|
case '$near':
|
|
case '$near':
|
|
|
case '$nearSphere':
|
|
case '$nearSphere':
|
|
|
|
|
+ var x = 'Temporary value until Geo fns implimented.';
|
|
|
return this.expressionParserGeoCallback(name, x, context);
|
|
return this.expressionParserGeoCallback(name, x, context);
|
|
|
-
|
|
|
|
|
|
|
+ default:
|
|
|
|
|
+ return {code:ErrorCodes.BAD_VALUE, description:"not handled: " + element};
|
|
|
} // end switch
|
|
} // end switch
|
|
|
|
|
|
|
|
|
|
|