From 7bc4f06b6eb80a3d52f8689d4fac8918bce414a2 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Thu, 30 Jan 2014 23:12:40 +0100 Subject: [PATCH] fixed failing tests --- arangod/V8Server/v8-query.cpp | 12 ++++++++---- js/server/modules/org/arangodb/arango-collection.js | 9 ++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arangod/V8Server/v8-query.cpp b/arangod/V8Server/v8-query.cpp index e68146e7c1..630cfb6bc8 100644 --- a/arangod/V8Server/v8-query.cpp +++ b/arangod/V8Server/v8-query.cpp @@ -2459,8 +2459,10 @@ static v8::Handle JS_FirstQuery (v8::Arguments const& argv) { // if argument is supplied, we'll return a list - otherwise we simply return the first doc if (argv.Length() == 1) { - count = TRI_ObjectToInt64(argv[0]); - returnList = true; + if (! argv[0]->IsUndefined()) { + count = TRI_ObjectToInt64(argv[0]); + returnList = true; + } } if (count < 1) { @@ -2714,8 +2716,10 @@ static v8::Handle JS_LastQuery (v8::Arguments const& argv) { // if argument is supplied, we'll return a list - otherwise we simply return the last doc if (argv.Length() == 1) { - count = TRI_ObjectToInt64(argv[0]); - returnList = true; + if (! argv[0]->IsUndefined()) { + count = TRI_ObjectToInt64(argv[0]); + returnList = true; + } } if (count < 1) { diff --git a/js/server/modules/org/arangodb/arango-collection.js b/js/server/modules/org/arangodb/arango-collection.js index ccf8e4bcfe..79e16804b6 100644 --- a/js/server/modules/org/arangodb/arango-collection.js +++ b/js/server/modules/org/arangodb/arango-collection.js @@ -324,11 +324,12 @@ ArangoCollection.prototype.first = function (count) { var body = JSON.parse(results[i].body); return body.result || null; } - return null; } else { return this.FIRST(count); } + + return null; }; //////////////////////////////////////////////////////////////////////////////// @@ -336,7 +337,7 @@ ArangoCollection.prototype.first = function (count) { /// /// @FUN{@FA{collection}.last(@FA{count})} /// -/// The @FN{first} method returns the n last documents from the collection, in +/// The @FN{lst} method returns the n last documents from the collection, in /// order of document insertion/update time. /// /// If called with the @FA{count} argument, the result is a list of up to @@ -405,7 +406,9 @@ ArangoCollection.prototype.last = function (count) { } else { return this.LAST(count); - } + } + + return null; }; ////////////////////////////////////////////////////////////////////////////////