2

Probably a silly question, but if in a collection I have documents which include attributes defined with spaces, example:

{
 "attribute with spaces" : "blabla",
 ...
}

How can I query for finding it? I tried

for document in documents
    filter document."attribute with spaces" == "blabla"

But of course I get a syntax error.

Vincenzo Lavorini
  • 1,884
  • 2
  • 15
  • 26

1 Answers1

3

Attribute names that are reserved keywords or contain spaces or other characters not allowed in attribute names must be quoted with backticks:

FOR document IN documents
    FILTER document.`attribute with spaces` == "blabla"

Alternatively you can use attribute access like this:

FOR document IN documents
    FILTER document["attribute with spaces"] == "blabla"

This is also explained in the documentation: https://www.arangodb.com/docs/stable/aql/fundamentals-syntax.html#names

mpoeter
  • 2,574
  • 1
  • 5
  • 12