Skip to content

Commit 9115c84

Browse files
committed
Improve QueryParser
* Calculate the memory usage when parsing a query * Change the way used to parse the extension on()
1 parent 2d989b6 commit 9115c84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/JSONDB/QueryParser.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function parse($query)
205205

206206
$this->parsedQuery['benchmark'] = array(
207207
'elapsed_time' => $benchmark->elapsed_time('jsondb_query_parse_start', 'jsondb_query_parse_end'),
208-
'memory_usage' => $benchmark->memory_usage()
208+
'memory_usage' => $benchmark->memory_usage('jsondb_query_parse_start', 'jsondb_query_parse_end')
209209
);
210210

211211
return $this->parsedQuery;
@@ -411,8 +411,11 @@ private function _parseOnExtension($clause)
411411
if (count($parsedClause) === 0) {
412412
throw new Exception("JSONDB Query Parse Error: At least one parameter expected for the \"on()\" extension.");
413413
}
414+
if (count($parsedClause) > 1) {
415+
throw new Exception("JSONDB Query Parse Error: Too much parameters given to the \"on()\" extension, only one required.");
416+
}
414417

415-
return $parsedClause;
418+
return $parsedClause[0];
416419
}
417420

418421
private function _parseLinkExtension($clause)

0 commit comments

Comments
 (0)