mirror of https://gitee.com/bigwinds/arangodb
renamed function
This commit is contained in:
parent
5fda62b725
commit
71c050d2fa
|
@ -20,7 +20,7 @@ v2.3.0 (XXXX-XX-XX)
|
||||||
* added AQL string functions `LTRIM`, `RTRIM`, `FIND_FIRST`, `FIND_LAST`, `SPLIT`,
|
* added AQL string functions `LTRIM`, `RTRIM`, `FIND_FIRST`, `FIND_LAST`, `SPLIT`,
|
||||||
`SUBSTITUTE`
|
`SUBSTITUTE`
|
||||||
|
|
||||||
* added AQL functions `ASSEMBLE` and `VALUES`
|
* added AQL functions `ZIP` and `VALUES`
|
||||||
|
|
||||||
* made AQL functions `CONCAT` and `CONCAT_SEPARATOR` work with list arguments
|
* made AQL functions `CONCAT` and `CONCAT_SEPARATOR` work with list arguments
|
||||||
|
|
||||||
|
|
|
@ -94,15 +94,14 @@ AQL supports the following functions to operate on document values:
|
||||||
as a list. If *removeInternal* is set to *true*, then all internal attributes (such
|
as a list. If *removeInternal* is set to *true*, then all internal attributes (such
|
||||||
as *_id*, *_key* etc.) are removed from the result.
|
as *_id*, *_key* etc.) are removed from the result.
|
||||||
|
|
||||||
- *ASSEMBLE(attributes, values)*: Returns a document object assembled from the
|
- *ZIP(attributes, values)*: Returns a document object assembled from the
|
||||||
separate parameters *attributes* and *values*. *attributes* and *values* must be
|
separate parameters *attributes* and *values*. *attributes* and *values* must be
|
||||||
lists and must have the same length. The items in *attributes* will be used for
|
lists and must have the same length. The items in *attributes* will be used for
|
||||||
naming the attributes in the result. The items in *values* will be used as the
|
naming the attributes in the result. The items in *values* will be used as the
|
||||||
actual values of the result.
|
actual values of the result.
|
||||||
|
|
||||||
/* { "name" : "some user", "active" : true, "hobbies" : [ "swimming", "riding" ] } */
|
/* { "name" : "some user", "active" : true, "hobbies" : [ "swimming", "riding" ] } */
|
||||||
ASSEMBLE([ 'name', 'active', 'hobbies' ],
|
ZIP([ 'name', 'active', 'hobbies' ], [ 'some user', true, [ 'swimming', 'riding' ] ])
|
||||||
[ 'some user', true, [ 'swimming', 'riding' ] ])
|
|
||||||
|
|
||||||
- *UNSET(document, attributename, ...)*: Removes the attributes *attributename*
|
- *UNSET(document, attributename, ...)*: Removes the attributes *attributename*
|
||||||
(can be one or many) from *document*. All other attributes will be preserved.
|
(can be one or many) from *document*. All other attributes will be preserved.
|
||||||
|
|
|
@ -167,7 +167,7 @@ std::unordered_map<std::string, Function const> const Executor::FunctionNames{
|
||||||
{ "UNSET", Function("UNSET", "AQL_UNSET", "a,sl|+", true, false, true) },
|
{ "UNSET", Function("UNSET", "AQL_UNSET", "a,sl|+", true, false, true) },
|
||||||
{ "KEEP", Function("KEEP", "AQL_KEEP", "a,sl|+", true, false, true) },
|
{ "KEEP", Function("KEEP", "AQL_KEEP", "a,sl|+", true, false, true) },
|
||||||
{ "TRANSLATE", Function("TRANSLATE", "AQL_TRANSLATE", ".,a|.", true, false, true) },
|
{ "TRANSLATE", Function("TRANSLATE", "AQL_TRANSLATE", ".,a|.", true, false, true) },
|
||||||
{ "ASSEMBLE", Function("ASSEMBLE", "AQL_ASSEMBLE", "l,l", true, false, true) },
|
{ "ZIP", Function("ZIP", "AQL_ZIP", "l,l", true, false, true) },
|
||||||
|
|
||||||
// geo functions
|
// geo functions
|
||||||
{ "NEAR", Function("NEAR", "AQL_NEAR", "h,n,n|nz,s", false, true, false) },
|
{ "NEAR", Function("NEAR", "AQL_NEAR", "h,n,n|nz,s", false, true, false) },
|
||||||
|
|
|
@ -3580,13 +3580,13 @@ function AQL_VALUES (element, removeInternal) {
|
||||||
/// @brief assemble a document from two lists
|
/// @brief assemble a document from two lists
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function AQL_ASSEMBLE (keys, values) {
|
function AQL_ZIP (keys, values) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (TYPEWEIGHT(keys) !== TYPEWEIGHT_LIST ||
|
if (TYPEWEIGHT(keys) !== TYPEWEIGHT_LIST ||
|
||||||
TYPEWEIGHT(values) !== TYPEWEIGHT_LIST ||
|
TYPEWEIGHT(values) !== TYPEWEIGHT_LIST ||
|
||||||
keys.length !== values.length) {
|
keys.length !== values.length) {
|
||||||
WARN("ASSEMBLE", INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH);
|
WARN("ZIP", INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4646,7 +4646,6 @@ function TRAVERSAL_FUNC (func,
|
||||||
weight : params.weight,
|
weight : params.weight,
|
||||||
defaultWeight : params.defaultWeight,
|
defaultWeight : params.defaultWeight,
|
||||||
prefill : params.prefill
|
prefill : params.prefill
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (params.followEdges) {
|
if (params.followEdges) {
|
||||||
|
@ -7276,7 +7275,7 @@ exports.AQL_SKIPLIST = AQL_SKIPLIST;
|
||||||
exports.AQL_HAS = AQL_HAS;
|
exports.AQL_HAS = AQL_HAS;
|
||||||
exports.AQL_ATTRIBUTES = AQL_ATTRIBUTES;
|
exports.AQL_ATTRIBUTES = AQL_ATTRIBUTES;
|
||||||
exports.AQL_VALUES = AQL_VALUES;
|
exports.AQL_VALUES = AQL_VALUES;
|
||||||
exports.AQL_ASSEMBLE = AQL_ASSEMBLE;
|
exports.AQL_ZIP = AQL_ZIP;
|
||||||
exports.AQL_UNSET = AQL_UNSET;
|
exports.AQL_UNSET = AQL_UNSET;
|
||||||
exports.AQL_KEEP = AQL_KEEP;
|
exports.AQL_KEEP = AQL_KEEP;
|
||||||
exports.AQL_MERGE = AQL_MERGE;
|
exports.AQL_MERGE = AQL_MERGE;
|
||||||
|
|
|
@ -1959,10 +1959,10 @@ function ahuacatlFunctionsTestSuite () {
|
||||||
},
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test assemble function
|
/// @brief test zip function
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
testAssemble : function () {
|
testZip : function () {
|
||||||
var values = [
|
var values = [
|
||||||
[ { }, [ ], [ ] ],
|
[ { }, [ ], [ ] ],
|
||||||
[ { "" : true }, [ "" ], [ true ] ],
|
[ { "" : true }, [ "" ], [ true ] ],
|
||||||
|
@ -1975,38 +1975,38 @@ function ahuacatlFunctionsTestSuite () {
|
||||||
];
|
];
|
||||||
|
|
||||||
values.forEach(function (value) {
|
values.forEach(function (value) {
|
||||||
var actual = getQueryResults("RETURN ASSEMBLE(" + JSON.stringify(value[1]) + ", " + JSON.stringify(value[2]) + ")");
|
var actual = getQueryResults("RETURN ZIP(" + JSON.stringify(value[1]) + ", " + JSON.stringify(value[2]) + ")");
|
||||||
assertEqual(value[0], actual[0], value);
|
assertEqual(value[0], actual[0], value);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test assemble function
|
/// @brief test zip function
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
testAssembleInvalid : function () {
|
testZipInvalid : function () {
|
||||||
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ASSEMBLE()");
|
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ZIP()");
|
||||||
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ASSEMBLE([ ])");
|
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ZIP([ ])");
|
||||||
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ASSEMBLE([ ], [ ], [ ])");
|
assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN ZIP([ ], [ ], [ ])");
|
||||||
|
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], null)");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], null)");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], false)");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], false)");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], true)");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], true)");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], 0)");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], 0)");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], 1)");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], 1)");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], \"\")");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], \"\")");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], { })");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], { })");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(null, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(null, [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(false, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(false, [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(true, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(true, [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(0, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(0, [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(1, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(1, [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE(\"\", [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP(\"\", [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE({ }, [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP({ }, [ ])");
|
||||||
|
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ 1 ], [ ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ 1 ], [ ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ 1 ], [ 1, 2 ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ 1 ], [ 1, 2 ])");
|
||||||
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ASSEMBLE([ ], [ 1, 2 ])");
|
assertQueryWarningAndNull(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN ZIP([ ], [ 1, 2 ])");
|
||||||
},
|
},
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue