mirror of https://gitee.com/bigwinds/arangodb
Fix for #546
This commit is contained in:
parent
54b0552dee
commit
8e27de26a7
|
@ -30,6 +30,7 @@
|
|||
|
||||
var arangodb = require("org/arangodb");
|
||||
var arangosh = require("org/arangodb/arangosh");
|
||||
var is = require("org/arangodb/is");
|
||||
|
||||
var ArangoQueryCursor = require("org/arangodb/arango-query-cursor").ArangoQueryCursor;
|
||||
|
||||
|
@ -438,8 +439,7 @@ Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
|
|||
|
||||
if (data === null || typeof data !== "object") {
|
||||
params = {};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
params = data._shallowCopy || {};
|
||||
}
|
||||
|
||||
|
@ -448,6 +448,10 @@ Graph.prototype.addEdge = function (out_vertex, in_vertex, id, label, data) {
|
|||
params._to = in_vertex._properties._key;
|
||||
params.$label = label;
|
||||
|
||||
if (is.notExisty(params.$label) && is.existy(data) && is.existy(data.$label)) {
|
||||
params.$label = data.$label;
|
||||
}
|
||||
|
||||
requestResult = this._connection.POST("/_api/graph/"
|
||||
+ encodeURIComponent(this._properties._key) + "/edge",
|
||||
JSON.stringify(params));
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true, eqeq: true */
|
||||
/*global require, exports */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Check if something is something
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler, Lucas Dohmen
|
||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Check if a value is not undefined or null
|
||||
var existy = function (x) {
|
||||
"use strict";
|
||||
// This is != on purpose to also check for undefined
|
||||
return x != null;
|
||||
};
|
||||
|
||||
// Check if a value is undefined or null
|
||||
var notExisty = function (x) {
|
||||
"use strict";
|
||||
return !existy(x);
|
||||
};
|
||||
|
||||
// Check if a value is existy and not false
|
||||
var truthy = function (x) {
|
||||
"use strict";
|
||||
return (x !== false) && existy(x);
|
||||
};
|
||||
|
||||
// Check if a value is not truthy
|
||||
var falsy = function (x) {
|
||||
"use strict";
|
||||
return !truthy(x);
|
||||
};
|
||||
|
||||
exports.existy = existy;
|
||||
exports.notExisty = notExisty;
|
||||
exports.truthy = truthy;
|
||||
exports.falsy = falsy;
|
|
@ -250,6 +250,19 @@ function GraphBasicsSuite() {
|
|||
assertEqual("testValue", edge.getProperty("testProperty"));
|
||||
},
|
||||
|
||||
testAddEdgeWithLabelSetViaData : function () {
|
||||
var v1,
|
||||
v2,
|
||||
edge;
|
||||
|
||||
v1 = graph.addVertex("vertex1");
|
||||
v2 = graph.addVertex("vertex2");
|
||||
|
||||
edge = graph.addEdge(v1, v2, null, null, {"$label": "test"});
|
||||
|
||||
assertEqual("test", edge.getLabel());
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief change a property
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue