3

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?

ciscoheat
  • 3,719
  • 1
  • 35
  • 52

2 Answers2

4

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"
}
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
  • 1
    Another (maybe better) solution could be to [use bind variables](https://docs.arangodb.com/Aql/Invoke.html) in such a case. Can you mark your own answer as accepted? – dothebart Mar 07 '16 at 10:30
  • 1
    Ah, I didn't know bind variables could also be used for key names. Thanks, I'll update the answer. – ciscoheat Mar 07 '16 at 11:23
0

Field name can be escaped with backticks: FILTER p.`one-two`: AQL: How to specify a collection that has a dash in the name?

Leaving this here because the marked solution does not per se answer the question of the title.

Akira Taguchi
  • 111
  • 1
  • 7