Common Errors
String concatenation
In AQL, strings must be concatenated using the CONCAT()
function. Joining them together with the +
operator is not supported. Especially
as JavaScript programmer it is easy to walk into this trap:
RETURN "foo" + "bar" // [ 0 ]
RETURN "foo" + 123 // [ 123 ]
RETURN "123" + 200 // [ 323 ]
The arithmetic plus operator expects numbers as operands, and will try to implicitly
cast them to numbers if they are of different type. "foo"
and "bar"
are casted
to 0
and then added to together (still zero). If an actual number is added, that
number will be returned (adding zero doesn't change the result). If the string is a
valid string representation of a number, then it is casted to a number. Thus, adding
"123"
and 200
results in two numbers being added up to 323
.
To concatenate elements (with implicit casting to string for non-string values), do:
RETURN CONCAT("foo", "bar") // [ "foobar" ]
RETURN CONCAT("foo", 123) // [ "foo123" ]
RETURN CONCAT("123", 200) // [ "123200" ]