如何修复AQL语法错误? 我正在尝试使用查询创建边,但是出现以下错误:
无法执行查询。响应:400,错误:1501-AQL:语法错误,查询字符串的意外结束在位置1:57处的'@edges'附近(解析时)
用于执行查询的代码:
try {
String query = "INSERT { _from:TurmaA._teste2, _to:TurmaA._testepedro } IN @edges";
Map<String, Object> bindVars = new MapBuilder().put("edges", nome2).get();
ArangoCursor<BaseDocument> cursor = arangoDB.db(dbName).query(query, bindVars,
null, BaseDocument.class);
cursor.forEachRemaining(aDocument -> {
System.out.println("Key: " + aDocument.getKey());
});
} catch (ArangoDBException e) {
System.err.println("Failed to execute query. " + e.getMessage());
}
答案 0 :(得分:0)
请注意,collection bind variables have to be prefixed by two @@
。
因此,您的代码示例可以像这样轻松地固定:
try {
String query = "INSERT { _from:TurmaA._teste2, _to:TurmaA._testepedro } IN @@edges";
Map<String, Object> bindVars = new MapBuilder().put("@edges", nome2).get();
ArangoCursor<BaseDocument> cursor = arangoDB.db(dbName).query(query, bindVars,
null, BaseDocument.class);
cursor.forEachRemaining(aDocument -> {
System.out.println("Key: " + aDocument.getKey());
});
} catch (ArangoDBException e) {
System.err.println("Failed to execute query. " + e.getMessage());
}