Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix syntax errors on comparison & sorting queries

  • Loading branch information...
commit c4d0ac865907d0555dc5da85fa436a19fab31f38 1 parent bc58bf2
Kris Zyp kriszyp authored

Showing 1 changed file with 6 additions and 6 deletions. Show diff stats Hide diff stats

  1. +6 6 lib/resource-query.js
12 lib/resource-query.js
@@ -136,16 +136,16 @@ exports.executeQuery = function(query, options, target){
136 136 query = parseQuery(query, options && options.parameters);
137 137 }
138 138 var functions = options.functions || exports.QueryFunctions.prototype;
139   - var first = true;
  139 + var inComparision = false;
140 140 var js = "";
141 141 query.forEach(function(term){
142 142 if(term.type == "comparison"){
143 143 if(!options){
144 144 throw new Error("Values must be set as parameters on the options argument, which was not provided");
145 145 }
146   - if(first){
  146 + if(!inComparision){
  147 + inComparision = true;
147 148 js += "target = target.filter(function(item){return ";
148   - first = false;
149 149 }
150 150 else{
151 151 js += term.logic + term.logic;
@@ -158,9 +158,9 @@ exports.executeQuery = function(query, options, target){
158 158
159 159 }
160 160 else if(term.type == "call"){
161   - if(!first){
  161 + if(inComparision){
162 162 js += "});";
163   - first = false;
  163 + inComparision = false;
164 164 }
165 165 if(functions[term.name]){
166 166 var index = (options.parameters = options.parameters || []).push(term.parameters);
@@ -174,7 +174,7 @@ exports.executeQuery = function(query, options, target){
174 174 throw new URIError("Invalid query syntax, unknown type");
175 175 }
176 176 });
177   - if(!first){
  177 + if(inComparision){
178 178 js += "});";
179 179 first = false;
180 180 }

0 comments on commit c4d0ac8

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