1
0
Fork 0
This commit is contained in:
Jan Steemann 2016-03-22 10:51:42 +01:00
parent e7271f6e58
commit 45cc15fe45
11 changed files with 33 additions and 136 deletions

View File

@ -37,10 +37,10 @@ describe ArangoDB do
cmd = "/_api/document/123456"
doc = ArangoDB.log_delete("#{prefix}-bad-handle", cmd)
doc.code.should eq(400)
doc.code.should eq(404)
doc.parsed_response['error'].should eq(true)
doc.parsed_response['errorNum'].should eq(400)
doc.parsed_response['code'].should eq(400)
doc.parsed_response['errorNum'].should eq(1203) # collection not found
doc.parsed_response['code'].should eq(404)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
end

View File

@ -981,9 +981,10 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_id = doc.parsed_response['edge']['_id']
e_to = doc.parsed_response['edge']['_to']
e_from = doc.parsed_response['edge']['_from']
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(201)
doc1.parsed_response['error'].should eq(false)
@ -1020,9 +1021,10 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_id = doc.parsed_response['edge']['_id']
e_to = doc.parsed_response['edge']['_to']
e_from = doc.parsed_response['edge']['_from']
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(202)
doc1.parsed_response['error'].should eq(false)
@ -1035,7 +1037,7 @@ describe ArangoDB do
doc1.parsed_response['edge']['$label'].should eq("label1")
cmd = "/_api/graph/#{graph_name}/edge/#{e_id}?waitForSync=true"
body = "{\"_key\" : \"edge4711\", \"optional1\" : \"val1_huhu\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional1\" : \"val1_huhu\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc1 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc1.code.should eq(201)
doc1.parsed_response['error'].should eq(false)
@ -1046,7 +1048,6 @@ describe ArangoDB do
doc1.parsed_response['edge']['optional2'].should eq(nil)
doc1.parsed_response['edge']['optional1'].should eq("val1_huhu")
doc1.parsed_response['edge']['$label'].should eq("label1")
end
it "checks replace edge properties with if-match" do
@ -1060,6 +1061,8 @@ describe ArangoDB do
e_key = doc.parsed_response['edge']['_key']
e_rev = doc.parsed_response['edge']['_rev']
e_from = doc.parsed_response['edge']['_from']
e_to = doc.parsed_response['edge']['_to']
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}?rev=123"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
@ -1069,7 +1072,7 @@ describe ArangoDB do
doc1.parsed_response['code'].should eq(412)
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}?rev=#{e_rev}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc2 = ArangoDB.log_put("#{prefix}", cmd, :body => body)
doc2.code.should eq(201)
doc2.parsed_response['error'].should eq(false)
@ -1079,13 +1082,13 @@ describe ArangoDB do
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}"
hdr = { "if-match" => "123456" }
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body, :headers => hdr)
doc3.code.should eq(412)
cmd = "/_api/graph/#{graph_name}/edge/#{e_key}"
hdr = { "if-match" => "#{e_rev}" }
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_to\" : \"to\"}"
body = "{\"_key\" : \"edge4711\", \"optional2\" : \"val2\", \"$label\" : \"label2\", \"_from\" : \"#{e_from}\", \"_to\" : \"#{e_to}\"}"
doc3 = ArangoDB.log_put("#{prefix}", cmd, :body => body, :headers => hdr)
doc3.code.should eq(201)

View File

@ -78,24 +78,6 @@ TRI_document_collection_t* Collection::documentCollection() const {
return collection->_collection;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is an edge collection
////////////////////////////////////////////////////////////////////////////////
bool Collection::isEdgeCollection() const {
auto document = documentCollection();
return (document->_info.type() == TRI_COL_TYPE_EDGE);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is a document collection
//////////////////////////////////////////////////////////////////////////////
bool Collection::isDocumentCollection() const {
auto document = documentCollection();
return (document->_info.type() == TRI_COL_TYPE_DOCUMENT);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief count the number of documents in the collection
////////////////////////////////////////////////////////////////////////////////
@ -189,30 +171,6 @@ std::vector<Index const*> Collection::getIndexes() const {
return indexes;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
////////////////////////////////////////////////////////////////////////////////
Index const* Collection::getIndex(TRI_idx_iid_t id) const {
fillIndexes();
for (auto const& idx : indexes) {
if (idx->id == id) {
return idx;
}
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
////////////////////////////////////////////////////////////////////////////////
Index const* Collection::getIndex(std::string const& id) const {
return getIndex(arangodb::basics::StringUtils::uint64(id));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection uses the default sharding
////////////////////////////////////////////////////////////////////////////////

View File

@ -88,18 +88,6 @@ struct Collection {
TRI_document_collection_t* documentCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is an edge collection
//////////////////////////////////////////////////////////////////////////////
bool isEdgeCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection is a document collection
//////////////////////////////////////////////////////////////////////////////
bool isDocumentCollection() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief count the LOCAL number of documents in the collection
//////////////////////////////////////////////////////////////////////////////
@ -130,18 +118,6 @@ struct Collection {
std::vector<Index const*> getIndexes() const;
//////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
//////////////////////////////////////////////////////////////////////////////
Index const* getIndex(TRI_idx_iid_t) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief return an index by its id
//////////////////////////////////////////////////////////////////////////////
Index const* getIndex(std::string const&) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the collection uses the default sharding
//////////////////////////////////////////////////////////////////////////////

View File

@ -121,32 +121,6 @@ bool Index::supportsSortCondition(
itemsInIndex, estimatedCost);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief get an iterator for the index
////////////////////////////////////////////////////////////////////////////////
arangodb::IndexIterator* Index::getIterator(
arangodb::Transaction* trx, arangodb::IndexIteratorContext* context,
arangodb::aql::Ast* ast, arangodb::aql::AstNode const* condition,
arangodb::aql::Variable const* reference, bool reverse) const {
TRI_ASSERT(hasInternals());
return getInternals()->iteratorForCondition(trx, context, ast, condition,
reference, reverse);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief specialize the condition for the index
/// this will remove all nodes from the condition that the index cannot
/// handle
////////////////////////////////////////////////////////////////////////////////
arangodb::aql::AstNode* Index::specializeCondition(
arangodb::aql::AstNode* node,
arangodb::aql::Variable const* reference) const {
TRI_ASSERT(hasInternals());
return getInternals()->specializeCondition(node, reference);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief append the index to an output stream
////////////////////////////////////////////////////////////////////////////////

View File

@ -181,26 +181,6 @@ struct Index {
arangodb::aql::Variable const*, size_t,
double&) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief get an iterator for the index
//////////////////////////////////////////////////////////////////////////////
arangodb::IndexIterator* getIterator(arangodb::Transaction*,
arangodb::IndexIteratorContext*,
arangodb::aql::Ast*,
arangodb::aql::AstNode const*,
arangodb::aql::Variable const*,
bool) const;
//////////////////////////////////////////////////////////////////////////////
/// @brief specialize the condition for the index
/// this will remove all nodes from the condition that the index cannot
/// handle
//////////////////////////////////////////////////////////////////////////////
arangodb::aql::AstNode* specializeCondition(
arangodb::aql::AstNode*, arangodb::aql::Variable const*) const;
public:
TRI_idx_iid_t const id;
arangodb::Index::IndexType type;

View File

@ -619,7 +619,7 @@ QueryResult Query::execute(QueryRegistry* registry) {
AqlItemBlock* value = nullptr;
auto resultBuilder = std::make_shared<VPackBuilder>();
try {
VPackArrayBuilder guard(resultBuilder.get());
resultBuilder->openArray();
// this is the RegisterId our results can be found in
auto const resultRegister = _engine->resultRegister();
@ -640,6 +640,10 @@ QueryResult Query::execute(QueryRegistry* registry) {
value = nullptr;
}
// must close result array here because it must be passed as a closed array
// to the query cache
resultBuilder->close();
if (_warnings.empty()) {
// finally store the generated result in the query cache
auto result = QueryCache::instance()->store(
@ -666,6 +670,9 @@ QueryResult Query::execute(QueryRegistry* registry) {
delete value;
value = nullptr;
}
// must close result array
resultBuilder->close();
}
} catch (...) {
delete value;

View File

@ -222,18 +222,14 @@ void RestJobHandler::getJobByType(std::string const& type) {
}
try {
VPackBuilder json;
json.add(VPackValue(VPackValueType::Array));
VPackBuilder result;
result.add(VPackValue(VPackValueType::Array));
size_t const n = ids.size();
for (size_t i = 0; i < n; ++i) {
char* idString = TRI_StringUInt64(ids[i]);
if (idString != nullptr) {
json.add(VPackValue(idString));
result.add(VPackValue(std::to_string(ids[i])));
}
}
json.close();
VPackSlice slice(json.start());
generateResult(slice);
result.close();
generateResult(result.slice());
} catch (...) {
generateError(HttpResponse::SERVER_ERROR, TRI_ERROR_OUT_OF_MEMORY);
}

View File

@ -782,6 +782,12 @@ function update_graph_edge (req, res, g, isPatch) {
}
var shallow = json._shallowCopy;
if (json.hasOwnProperty('_from')) {
shallow._from = json._from;
}
if (json.hasOwnProperty('_to')) {
shallow._to = json._to;
}
shallow.$label = e._properties.$label;
var id2 = null;

View File

@ -32,9 +32,6 @@
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief shallow copies properties
////////////////////////////////////////////////////////////////////////////////

View File

@ -205,7 +205,7 @@ SimpleQueryNear.prototype.execute = function () {
"@collection": this._collection.name(),
latitude: this._latitude,
longitude: this._longitude,
limit: this._limit
limit: parseInt(this._limit + this._skip, 10)
};
var mustSort = false;