Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix syntax errors on comparison & sorting queries

  • Loading branch information...
commit c4d0ac865907d0555dc5da85fa436a19fab31f38 1 parent bc58bf2
Kris Zyp kriszyp authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/resource-query.js
12 lib/resource-query.js
View
@@ -136,16 +136,16 @@ exports.executeQuery = function(query, options, target){
query = parseQuery(query, options && options.parameters);
}
var functions = options.functions || exports.QueryFunctions.prototype;
- var first = true;
+ var inComparision = false;
var js = "";
query.forEach(function(term){
if(term.type == "comparison"){
if(!options){
throw new Error("Values must be set as parameters on the options argument, which was not provided");
}
- if(first){
+ if(!inComparision){
+ inComparision = true;
js += "target = target.filter(function(item){return ";
- first = false;
}
else{
js += term.logic + term.logic;
@@ -158,9 +158,9 @@ exports.executeQuery = function(query, options, target){
}
else if(term.type == "call"){
- if(!first){
+ if(inComparision){
js += "});";
- first = false;
+ inComparision = false;
}
if(functions[term.name]){
var index = (options.parameters = options.parameters || []).push(term.parameters);
@@ -174,7 +174,7 @@ exports.executeQuery = function(query, options, target){
throw new URIError("Invalid query syntax, unknown type");
}
});
- if(!first){
+ if(inComparision){
js += "});";
first = false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.