arangodb/spring-data

how to use collection placeholder?

woshishitou opened this issue · 3 comments

I try to use collection placeholder in query, but I get error for it.

query:
@Query("FOR u IN @table FILTER u._key == @rowKey RETURN u")
List<Map<String, Object>> getNode(@Param("table") String table, @Param("rowKey") String rowKey);

error:
Response: 400, Error: 1563 - AQL: collection or array expected as operand to FOR loop; you specified type 'string' with content '"account"' (while optimizing ast)

Why this error happen? And How can I user collection placeholder correctly?

Bind parameters identifying a collection should be prefixed by @, see https://www.arangodb.com/docs/3.10/aql/fundamentals-bind-parameters.html#collection-bind-parameters

So your code should be:

@Query("FOR u IN @@table FILTER u._key == @rowKey RETURN u")
List<Map<String, Object>> getNode(@Param("@table") String table, @Param("rowKey") String rowKey);

Closing as inactive, please reopen in case of further questions.

Thank you very much!