mirror of https://gitee.com/bigwinds/arangodb
documentation for ternary operator shortcut
This commit is contained in:
parent
ec1e05975f
commit
2c431ea9f1
10
CHANGELOG
10
CHANGELOG
|
@ -1,6 +1,16 @@
|
||||||
devel
|
devel
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* added shortcut for AQL ternary operator
|
||||||
|
instead of `condition ? true-part : false-part` it is now possible to also use a
|
||||||
|
shortcut variant `condition ? : false-part`, e.g.
|
||||||
|
|
||||||
|
FOR doc IN docs RETURN doc.value ?: 'not present'
|
||||||
|
|
||||||
|
instead of
|
||||||
|
|
||||||
|
FOR doc IN docs RETURN doc.value ? doc.value : 'not present'
|
||||||
|
|
||||||
* fixed wrong sorting order in cluster, if an index was used to sort with many
|
* fixed wrong sorting order in cluster, if an index was used to sort with many
|
||||||
shards.
|
shards.
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,27 @@ function ahuacatlTernaryTestSuite () {
|
||||||
assertEqual([ 2 ], getQueryResults("RETURN NOOPT([ ] ? 2 : 3)"));
|
assertEqual([ 2 ], getQueryResults("RETURN NOOPT([ ] ? 2 : 3)"));
|
||||||
assertEqual([ 2 ], getQueryResults("RETURN NOOPT([ 0 ] ? 2 : 3)"));
|
assertEqual([ 2 ], getQueryResults("RETURN NOOPT([ 0 ] ? 2 : 3)"));
|
||||||
assertEqual([ 2 ], getQueryResults("RETURN NOOPT({ } ? 2 : 3)"));
|
assertEqual([ 2 ], getQueryResults("RETURN NOOPT({ } ? 2 : 3)"));
|
||||||
}
|
},
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test ternary operator shortcut
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
testTernaryShortcut : function () {
|
||||||
|
var expected = [ 'foo', 'foo', 1, 2 ];
|
||||||
|
|
||||||
|
var actual = getQueryResults("FOR i IN [ null, 0, 1, 2 ] RETURN i ? : 'foo'");
|
||||||
|
assertEqual(expected, actual);
|
||||||
|
|
||||||
|
actual = getQueryResults("FOR i IN [ null, 0, 1, 2 ] RETURN i ?: 'foo'");
|
||||||
|
assertEqual(expected, actual);
|
||||||
|
|
||||||
|
actual = getQueryResults("FOR i IN [ null, 0, 1, 2 ] RETURN NOOPT(i ? : 'foo')");
|
||||||
|
assertEqual(expected, actual);
|
||||||
|
|
||||||
|
actual = getQueryResults("FOR i IN [ null, 0, 1, 2 ] RETURN NOOPT(i ?: 'foo')");
|
||||||
|
assertEqual(expected, actual);
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue