Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beginner bug in FOR loops from objects?

Tags:

arangodb

I'm not sure if this is a stupid beginner question or if it is a bug. Tested in 3.1 and 3.4 Milestone ..

LET descriptions =  {
      "en": [
        "test1 test2"
      ],
      "de": [
        "test3 test4"
      ]
    }

// This one works:
//    FOR w IN descriptions.en RETURN w

// This one works NOT:
      FOR w IN descriptions.de RETURN w

What do I make wrong?

like image 770
augustin-s Avatar asked Jun 01 '26 16:06

augustin-s


1 Answers

This is a perfectly valid question. Running the query

LET descriptions = { "en": [ "test1 test2" ], "de": [ "test3 test4" ] }
FOR w IN descriptions.de 
  RETURN w

produces an unexpected error

ArangoError 1563: collection or array expected as operand to FOR loop; you specified type 'string' with content '{"en":["test1 test2"],"de":["test3 test4"]}.de' (while loading collections)

It works when using descriptions.en instead of descriptions.de, which really makes no sense from the user perspective.

Turns out to be a bug that will be fixed by the following pull request: https://github.com/arangodb/arangodb/pull/4522

like image 115
stj Avatar answered Jun 03 '26 06:06

stj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!