Search code examples
arangodbaql

How to quote/escape a field name in AQL for arangodb?


I cannot find where to quote a field name that has a space in it, for example when doing

FILTER s._key = a.`Supplier Id`

The above, sql-style quote doesn't work, neither does array access. What's the correct way?


Solution

  • Figured it out now, I got bitten by SQL and forgot that equality comparison is made with == in AQL. Then the array access worked, so the way to use field names with spaces is this:

    FILTER s._key == a['Supplier Id']
    

    If the field is without spaces but has some special characters, it works to use backtick instead of array access:

    FILTER s._key == a.`ÅterförsäljareId`
    

    Edit: Another option is to use bind variables:

    FILTER s._key == a.@field
    
    // Passing this to the API as bind variables:
    {
        "field": "Supplier Id"
    }